Database
public final class Databaseextension Database : QueryFactoryA Couchbase Lite database.
- 
                  
                  The default scope name constant DeclarationSwift public static let defaultScopeName: String
- 
                  
                  The default collection name constant DeclarationSwift public static let defaultCollectionName: String
- 
                  
                  Initializes a Couchbase Lite database with a given name and database options. If the database does not yet exist, it will be created, unless the readOnlyoption is used.Throws An error when the database cannot be opened.DeclarationSwift public init(name: String, config: DatabaseConfiguration = DatabaseConfiguration()) throwsParametersnameThe name of the database. configThe database options, or nil for the default options. 
- 
                  
                  The database’s name. DeclarationSwift public var name: String { get }
- 
                  
                  The database’s path. If the database is closed or deleted, nil value will be returned. DeclarationSwift public var path: String? { get }
- 
                  
                  The database configuration. DeclarationSwift public let config: DatabaseConfiguration
- 
                  
                  Save a blob object directly into the database without associating it with any documents. Note: Blobs that are not associated with any documents will be removed from the database when compacting the database. Throws An error on a failure.DeclarationSwift public func saveBlob(blob: Blob) throwsParametersblobThe blob to save. 
- 
                  
                  Get a blob object using a blob’s metadata. If the blob of the specified metadata doesn’t exist, the nil value will be returned. Throws An error on a failure. Note Note: Key | Value | Mandatory | Description@type | constant string “blob” | Yes | Indicate Blob data type. content_type | String | No | Content type ex. text/plain. length | Number | No | Binary length of the Blob in bytes. digest | String | Yes | The cryptographic digest of the Blob’s content. DeclarationSwift public func getBlob(properties: [String : Any]) throws -> Blob?ParameterspropertiesThe properties for getting the blob object. If dictionary is not valid, it will throw InvalidArgument exception. See the note section 
- 
                  
                  Runs a group of database operations in a batch. Use this when performing bulk write operations like multiple inserts/updates; it saves the overhead of multiple database commits, greatly improving performance. Throws An error on a failure.DeclarationSwift public func inBatch(using block: () throws -> Void) throwsParametersblockThe block to be executed as a batch operations. 
- 
                  
                  Close database synchronously. Before closing the database, the active replicators, listeners and live queries will be stopped. Throws An error on a failure.DeclarationSwift public func close() throws
- 
                  
                  Close and delete the database synchronously. Before closing the database, the active replicators, listeners and live queries will be stopped. Throws An error on a failure.DeclarationSwift public func delete() throws
- 
                  
                  Performs database maintenance. Throws An error on a failureDeclarationSwift public func performMaintenance(type: MaintenanceType) throws
- 
                  
                  Deletes a database of the given name in the given directory. Throws An error on a failure.DeclarationSwift public static func delete(withName name: String, inDirectory directory: String? = nil) throwsParametersnameThe database name. directoryThe directory where the database is located at. 
- 
                  
                  Checks whether a database of the given name exists in the given directory or not. DeclarationSwift public static func exists(withName name: String, inDirectory directory: String? = nil) -> BoolParametersnameThe database name. directoryThe directory where the database is located at. Return ValueTrue if the database exists, otherwise false. 
- 
                  
                  Copies a canned databaes from the given path to a new database with the given name and the configuration. The new database will be created at the directory specified in the configuration. Without given the database configuration, the default configuration that is equivalent to setting all properties in the configuration to nil will be used. Note This method will copy the database without changing the encryption key of the original database. The encryption key specified in the given config is the encryption key used for both the original and copied database. To change or add the encryption key for the copied database, call Database.changeEncryptionKey(key) for the copy.Note It is recommended to close the source database before calling this method. Throws An error on a failure. DeclarationSwift public static func copy(fromPath path: String, toDatabase name: String, withConfig config: DatabaseConfiguration?) throwsParameterspathThe source database path. nameThe name of the new database to be created. configThe database configuration for the new database name. 
- 
                  
                  Get the default scope. DeclarationSwift public func defaultScope() throws -> Scope
- 
                  
                  Get scope names that have at least one collection. Note: the default scope is exceptional as it will always be listed even though there are no collections under it. DeclarationSwift public func scopes() throws -> [Scope]
- 
                  
                  Get a scope object by name. As the scope cannot exist by itself without having a collection, the nil value will be returned if there are no collections under the given scope’s name. Note: The default scope is exceptional, and it will always be returned. DeclarationSwift public func scope(name: String) throws -> Scope?
- 
                  
                  Get the default collection. DeclarationSwift public func defaultCollection() throws -> Collection
- 
                  
                  Get all collections in the specified scope. DeclarationSwift public func collections(scope: String? = defaultScopeName) throws -> [Collection]
- 
                  
                  Create a named collection in the specified scope. If the collection already exists, the existing collection will be returned. DeclarationSwift public func createCollection(name: String, scope: String? = defaultScopeName) throws -> Collection
- 
                  
                  Get a collection in the specified scope by name. If the collection doesn’t exist, a nil value will be returned. DeclarationSwift public func collection(name: String, scope: String? = defaultScopeName) throws -> Collection?
- 
                  
                  Delete a collection by name in the specified scope. If the collection doesn’t exist, the operation will be no-ops. Note The default collection cannot be deleted.DeclarationSwift public func deleteCollection(name: String, scope: String? = defaultScopeName) throws
- 
                  
                  ENTERPRISE EDITION ONLY. Changes the database’s encryption key, or removes encryption if the new key is nil. Throws An error on a failure.DeclarationSwift public func changeEncryptionKey(_ key: EncryptionKey?) throwsParameterskeyThe encryption key. 
- 
                  
                  ENTERPRISE EDITION ONLY The predictive model manager for registering and unregistering predictive models. DeclarationSwift public static let prediction: Prediction
- 
                  
                  Creates a Query object from the given query string. Throws An error on when the given query string is invalid.DeclarationSwift public func createQuery(_ query: String) throws -> QueryParametersqueryQuery string. Return ValueA query created by the given query string. 
 Database Class Reference
        Database Class Reference