CBLDatabase
@interface CBLDatabase : NSObjectA Couchbase Lite database.
- 
                  
                  The database’s name. DeclarationObjective-C @property (readonly, nonatomic) NSString *_Nonnull name;Swift var name: String { get }
- 
                  
                  The database’s path. If the database is closed or deleted, nil value will be returned. DeclarationObjective-C @property (readonly, atomic, nullable) NSString *path;Swift var path: String? { get }
- 
                  
                  The number of documents in the database. DeclarationObjective-C @property (readonly, atomic) uint64_t count;Swift var count: UInt64 { get }
- 
                  
                  The database’s configuration. The returned configuration object is readonly; an NSInternalInconsistencyException exception will be thrown if the configuration object is modified. DeclarationObjective-C @property (readonly, nonatomic) CBLDatabaseConfiguration *_Nonnull config;Swift var config: CBLDatabaseConfiguration { get }
- 
                  
                  Initializes a database object with a given name and the default database configuration. If the database does not yet exist, it will be created. DeclarationObjective-C - (nullable instancetype)initWithName:(nonnull NSString *)name error:(NSError *_Nullable *_Nullable)error;Swift convenience init(name: String) throwsParametersnameThe name of the database. errorOn return, the error if any. 
- 
                  
                  Initializes a Couchbase Lite database with a given name and database configuration. If the database does not yet exist, it will be created. DeclarationObjective-C - (nullable instancetype)initWithName:(nonnull NSString *)name config: (nullable CBLDatabaseConfiguration *)config error:(NSError *_Nullable *_Nullable)error;Swift init(name: String, config: CBLDatabaseConfiguration?) throwsParametersnameThe name of the database. configThe database configuration, or nil for the default configuration. errorOn return, the error if any. 
- 
                  
                  Not available DeclarationObjective-C - (nonnull instancetype)init;
- 
                  
                  Gets an existing CBLMutableDocument object with the given ID. If the document with the given ID doesn’t exist in the database, the value returned will be nil. DeclarationObjective-C - (nullable CBLDocument *)documentWithID:(nonnull NSString *)id;Swift func document(withID id: String) -> CBLDocument?ParametersidThe document ID. Return ValueThe CBLMutableDocument object. 
- 
                  
                  Gets a document fragment with the given document ID. DeclarationObjective-C - (nonnull CBLDocumentFragment *)objectForKeyedSubscript: (nonnull NSString *)documentID;Swift subscript(documentID: String) -> CBLDocumentFragment { get }ParametersdocumentIDThe document ID. Return ValueThe CBLDocumentFragment object. 
- 
                  
                  Saves a document to the database. When write operations are executed concurrently, the last writer will overwrite all other written values. Calling this method is the same as calling the -saveDocument:concurrencyControl:error: method with kCBLConcurrencyControlLastWriteWins concurrency control. DeclarationObjective-C - (BOOL)saveDocument:(nonnull CBLMutableDocument *)document error:(NSError *_Nullable *_Nullable)error;Swift func save(_ document: CBLMutableDocument) throwsParametersdocumentThe document. errorOn return, the error if any. Return ValueTrue on success, false on failure. 
- 
                  
                  Saves a document to the database. When used with kCBLConcurrencyControlLastWriteWins concurrency control, the last write operation will win if there is a conflict. When used with kCBLConcurrencyControlFailOnConflict concurrency control, save will fail with ‘CBLErrorConflict’ error code returned. DeclarationObjective-C - (BOOL)saveDocument:(nonnull CBLMutableDocument *)document concurrencyControl:(CBLConcurrencyControl)concurrencyControl error:(NSError *_Nullable *_Nullable)error;Swift func save(_ document: CBLMutableDocument, concurrencyControl: CBLConcurrencyControl) throwsParametersdocumentThe document. concurrencyControlThe concurrency control. errorOn return, the error if any. Return ValueTrue on success, false on failure. 
- 
                  
                  Deletes a document from the database. When write operations are executed concurrently, the last writer will overwrite all other written values. Calling this method is the same as calling the -deleteDocument:concurrencyControl:error: method with kCBLConcurrencyControlLastWriteWins concurrency control. DeclarationObjective-C - (BOOL)deleteDocument:(nonnull CBLDocument *)document error:(NSError *_Nullable *_Nullable)error;Swift func delete(_ document: CBLDocument) throwsParametersdocumentThe document. errorOn return, the error if any. Return Value/True on success, false on failure. 
- 
                  
                  Deletes a document from the database. When used with kCBLConcurrencyControlLastWriteWins concurrency control, the last write operation will win if there is a conflict. When used with kCBLConcurrencyControlFailOnConflict concurrency control, delete will fail with ‘CBLErrorConflict’ error code returned. DeclarationObjective-C - (BOOL)deleteDocument:(nonnull CBLDocument *)document concurrencyControl:(CBLConcurrencyControl)concurrencyControl error:(NSError *_Nullable *_Nullable)error;Swift func delete(_ document: CBLDocument, concurrencyControl: CBLConcurrencyControl) throwsParametersdocumentThe document. concurrencyControlThe concurrency control. errorOn return, the error if any. Return ValueTrue on success, false on failure. 
- 
                  
                  Purges the given document from the database. This is more drastic than deletion: it removes all traces of the document. The purge will NOT be replicated to other databases. DeclarationObjective-C - (BOOL)purgeDocument:(nonnull CBLDocument *)document error:(NSError *_Nullable *_Nullable)error;Swift func purgeDocument(_ document: CBLDocument) throwsParametersdocumentThe document to be purged. errorOn return, the error if any. Return ValueTrue on success, false on failure. 
- 
                  
                  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. DeclarationObjective-C - (BOOL)inBatch:(NSError *_Nullable *_Nullable)error usingBlock:(nonnull void (^)(void))block;Swift func inBatch(usingBlock block: () -> Void) throwsParameterserrorOn return, the error if any. blockThe block to execute a group of database operations. Return ValueTrue on success, false on failure. 
- 
                  
                  Closes a database. DeclarationObjective-C - (BOOL)close:(NSError *_Nullable *_Nullable)error;Swift func close() throwsParameterserrorOn return, the error if any. Return ValueTrue on success, false on failure. 
- 
                  
                  Deletes a database. DeclarationObjective-C - (BOOL) delete:(NSError *_Nullable *_Nullable)error;Swift func delete() throwsParameterserrorOn return, the error if any. Return ValueTrue on success, false on failure. 
- 
                  
                  Compacts the database file by deleting unused attachment files and vacuuming the SQLite database DeclarationObjective-C - (BOOL)compact:(NSError *_Nullable *_Nullable)error;Swift func compact() throwsParameterserrorOn return, the error if any. Return ValueTrue on success, false on failure. 
- 
                  
                  Deletes a database of the given name in the given directory. DeclarationObjective-C + (BOOL)deleteDatabase:(nonnull NSString *)name inDirectory:(nullable NSString *)directory error:(NSError *_Nullable *_Nullable)error;Swift class func delete(_ name: String, inDirectory directory: String?) throwsParametersnameThe database name. directoryThe directory where the database is located at. errorOn return, the error if any. Return ValueTrue on success, false on failure. 
- 
                  
                  Checks whether a database of the given name exists in the given directory or not. DeclarationObjective-C + (BOOL)databaseExists:(nonnull NSString *)name inDirectory:(nullable NSString *)directory;Swift class func databaseExists(_ name: String, inDirectory directory: String?) -> BoolParametersnameThe database name. directoryThe directory where the database is located at. Return ValueTrue on success, false on failure. 
- 
                  
                  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. DeclarationObjective-C + (BOOL)copyFromPath:(nonnull NSString *)path toDatabase:(nonnull NSString *)name withConfig:(nullable CBLDatabaseConfiguration *)config error:(NSError *_Nullable *_Nullable)error;Swift class func copy(fromPath path: String, toDatabase name: String, withConfig config: CBLDatabaseConfiguration?) throwsParameterspathThe source database path. nameThe name of the new database to be created. configThe database configuration for the new database. errorOn return, the error if any. Return ValueTrue on success, false on failure. 
- 
                  
                  Sets log level for the given log domain. DeclarationObjective-C + (void)setLogLevel:(CBLLogLevel)level domain:(CBLLogDomain)domain;Swift class func setLogLevel(_ level: CBLLogLevel, domain: CBLLogDomain)ParameterslevelThe log level. domainThe log domain. 
- 
                  
                  Adds a database change listener. Changes will be posted on the main queue. DeclarationObjective-C - (nonnull id<CBLListenerToken>)addChangeListener: (nonnull void (^)(CBLDatabaseChange *_Nonnull))listener;ParameterslistenerThe listener to post the changes. Return ValueAn opaque listener token object for removing the listener. 
- 
                  
                  Adds a database change listener with the dispatch queue on which changes will be posted. If the dispatch queue is not specified, the changes will be posted on the main queue. DeclarationObjective-C - (nonnull id<CBLListenerToken>) addChangeListenerWithQueue:(nullable dispatch_queue_t)queue listener: (nonnull void (^)(CBLDatabaseChange *_Nonnull))listener;ParametersqueueThe dispatch queue. listenerThe listener to post changes. Return ValueAn opaque listener token object for removing the listener. 
- 
                  
                  Adds a document change listener for the document with the given ID. Changes will be posted on the main queue. DeclarationObjective-C - (nonnull id<CBLListenerToken>) addDocumentChangeListenerWithID:(nonnull NSString *)id listener:(nonnull void (^)(CBLDocumentChange *_Nonnull)) listener;ParametersidThe document ID. listenerThe listener to post changes. Return ValueAn opaque listener token object for removing the listener. 
- 
                  
                  Adds a document change listener for the document with the given ID and the dispatch queue on which changes will be posted. If the dispatch queue is not specified, the changes will be posted on the main queue. DeclarationObjective-C - (nonnull id<CBLListenerToken>) addDocumentChangeListenerWithID:(nonnull NSString *)id queue:(nullable dispatch_queue_t)queue listener:(nonnull void (^)(CBLDocumentChange *_Nonnull)) listener;ParametersidThe document ID. queueThe dispatch queue. listenerThe listener to post changes. Return ValueAn opaque listener token object for removing the listener. 
- 
                  
                  Removes a change listener with the given listener token. DeclarationObjective-C - (void)removeChangeListenerWithToken:(nonnull id<CBLListenerToken>)token;ParameterstokenThe listener token. 
- 
                  
                  All index names. DeclarationObjective-C @property (readonly, atomic) NSArray<NSString *> *_Nonnull indexes;Swift var indexes: [String] { get }
- 
                  
                  Creates an index which could be a value index or a full-text search index with the given name. The name can be used for deleting the index. Creating a new different index with an existing index name will replace the old index; creating the same index with the same name will be no-ops. DeclarationObjective-C - (BOOL)createIndex:(nonnull CBLIndex *)index withName:(nonnull NSString *)name error:(NSError *_Nullable *_Nullable)error;Swift func createIndex(_ index: CBLIndex, withName name: String) throwsParametersindexThe index. nameThe index name. errorerror On return, the error if any. Return ValueTrue on success, false on failure. 
- 
                  
                  Deletes the index of the given index name. DeclarationObjective-C - (BOOL)deleteIndexForName:(nonnull NSString *)name error:(NSError *_Nullable *_Nullable)error;Swift func deleteIndex(forName name: String) throwsParametersnameThe index name. errorerror On return, the error if any. Return ValueTrue on success, false on failure. 
- 
                  
                  Changes the database’s encryption key, or removes encryption if the new key is nil. DeclarationObjective-C - (BOOL)changeEncryptionKey:(nullable CBLEncryptionKey *)key error:(NSError *_Nullable *_Nullable)error;Swift func change(_ key: CBLEncryptionKey?) throwsParameterskeyThe encryption key. errorOn return, the error if any. Return ValueTrue if the database was successfully re-keyed, or false on failure. 
 CBLDatabase Class Reference
        CBLDatabase Class Reference