CouchDBClient

public class CouchDBClient

The CouchDBClient represents a connection to a CouchDB server. It is initialized with your ConnectionProperties and handles the creation, retrieval and deletion of CouchDB databases.

Usage Example:

let conProperties = ConnectionProperties(
    host: "127.0.0.1",              // http address
    port: 5984,                     // http port
    secured: false,                 // https or http
    username: "<CouchDB-username>", // admin username
    password: "<CouchDB-password>"  // admin password
)
let couchDBClient = CouchDBClient(connectionProperties: conProperties)
  • Create a new Database.

    Usage Example:

    couchDBClient.createDB("NewDB") { (database, error) in
        if let database = database {
           // Use database
        }
    }
    

    Declaration

    Swift

    public func createDB(_ dbName: String, callback: @escaping (Database?, CouchDBError?) -> ())
  • Get an existing Database from the CouchDB Server.

    Usage Example:

    couchDBClient.retrieveDB("ExistingDB") { (database, error) in
       if let database = database {
           // Use database
       }
    }
    

    Declaration

    Swift

    public func retrieveDB(_ dbName: String, callback: @escaping (Database?, CouchDBError?) -> ())
  • Delete a Database given a local instance of it.

    Declaration

    Swift

    public func deleteDB(_ database: Database, callback: @escaping (CouchDBError?) -> ())

    Parameters

    database

    An instance of the Database to delete.

    callback

    Callback containing a CouchDBError if one occurred.

  • Usage Example:

    couchDBClient.deleteDB("ExistingDB") { (error) in
       if let error = error {
           // Handle the error
       }
    }
    

    Declaration

    Swift

    public func deleteDB(_ dbName: String, callback: @escaping (CouchDBError?) -> ())
  • Returns some UUIDs created by CouchDB.

    Declaration

    Swift

    public func getUUIDs(count : UInt, callback : @escaping ([String]?, CouchDBError?) -> Void)

    Parameters

    count

    The number of UUIDs to get.

    callback

    Callback containing an array of UUIDs or a CouchDBError if one occured.

  • Returns a UUID created by CouchDB.

    Declaration

    Swift

    public func getUUID(callback : @escaping (String?, CouchDBError?) -> Void)

    Parameters

    callback

    Callback containing the UUID or a CouchDBError if one occurred.