Database class abstract Database

A Couchbase Lite database.

Implemented types
Implementers

Constructors

Database()

Properties

config DatabaseConfiguration
The configuration which was used to open this database.
no setter
count FutureOr<int>
The total number of documents in the database.
no setter
hashCode int
The hash code for this object.
no setterinherited
indexes FutureOr<List<String>>
The names of all existing indexes.
no setter
isClosed bool
Whether this resource has been closed.
no setterinherited
name String
The name of this database.
no setter
path String?
The path to this database.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addChangeListener(DatabaseChangeListener listener) FutureOr<ListenerToken>
Adds a listener to be notified of all changes to Documents in this database.
addDocumentChangeListener(String id, DocumentChangeListener listener) FutureOr<ListenerToken>
Adds a listener to be notified of changes to the Document with the given id.
changeEncryptionKey(EncryptionKey? newKey) FutureOr<void>
Encrypts or decrypts a Database, or changes its EncryptionKey.
changes() Stream<DatabaseChange>
Returns a Stream to be notified of all changes to Documents in this database.
close() Future<void>
Closes this database.
override
createIndex(String name, Index index) FutureOr<void>
Creates a value or full-text search index with the given name.
delete() Future<void>
Closes and deletes this database.
deleteDocument(Document document, [ConcurrencyControl concurrencyControl = ConcurrencyControl.lastWriteWins]) FutureOr<bool>
Deletes a document from this database, resolving conflicts through ConcurrencyControl.
deleteIndex(String name) FutureOr<void>
Deletes the Index of the given name.
deleteTypedDocument(TypedDocumentObject<Object> document, [ConcurrencyControl concurrencyControl = ConcurrencyControl.lastWriteWins]) FutureOr<bool>
Deletes a typed document from this database, resolving conflicts through ConcurrencyControl.
document(String id) FutureOr<Document?>
Returns the Document with the given id, if it exists.
documentChanges(String id) Stream<DocumentChange>
Returns a Stream to be notified of changes to the Document with the given id.
getBlob(Map<String, Object?> properties) FutureOr<Blob?>
Gets a Blob using its metadata.
getDocumentExpiration(String id) FutureOr<DateTime?>
Gets the expiration date of a Document by its id, if it exists.
inBatch(FutureOr<void> fn()) Future<void>
Runs a group of database operations in a batch.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
performMaintenance(MaintenanceType type) FutureOr<void>
Performs database maintenance.
purgeDocument(Document document) FutureOr<void>
Purges a document from this database.
purgeDocumentById(String id) FutureOr<void>
Purges a Document from this database by its id.
purgeTypedDocument(TypedDocumentObject<Object> document) FutureOr<void>
Purges a typed document from this database.
removeChangeListener(ListenerToken token) FutureOr<void>
Removes a previously added change listener.
saveBlob(Blob blob) FutureOr<void>
Saves a Blob directly into this database without associating it with any Documents.
saveDocument(MutableDocument document, [ConcurrencyControl concurrencyControl = ConcurrencyControl.lastWriteWins]) FutureOr<bool>
Saves a document to this database, resolving conflicts through ConcurrencyControl.
saveDocumentWithConflictHandler(MutableDocument document, SaveConflictHandler conflictHandler) FutureOr<bool>
Saves a document to this database, resolving conflicts with a conflictHandler.
saveTypedDocument<D extends TypedDocumentObject<Object>, MD extends TypedMutableDocumentObject<TypedDocumentObject<Object>, TypedDocumentObject<Object>>>(TypedMutableDocumentObject<D, MD> document) SaveTypedDocument<D, MD>
Creates and returns an object, which can be used to save a typed document to this database.
setDocumentExpiration(String id, DateTime? expiration) FutureOr<void>
Sets an expiration date for a Document by its id.
toString() String
A string representation of this object.
inherited
typedDocument<D extends TypedDocumentObject<Object>>(String id) FutureOr<D?>
Returns the typed document, with type D and the given id, if it exists.

Operators

operator ==(Object other) bool
The equality operator.
inherited
operator [](String id) FutureOr<DocumentFragment>
Returns the DocumentFragment for the Document with the given id.

Static Properties

log Log
Configuration of the ConsoleLogger, FileLogger and a custom Logger.
final

Static Methods

copy({required String from, required String name, DatabaseConfiguration? config}) Future<void>
Copies a canned database from the given path to a new database with the given name and config.
copySync({required String from, required String name, DatabaseConfiguration? config}) → void
Copies a canned database from the given path to a new database with the given name and config.
exists(String name, {String? directory}) Future<bool>
Checks whether a database of the given name exists in the given directory or not.
existsSync(String name, {String? directory}) bool
Checks whether a database of the given name exists in the given directory or not.
openAsync(String name, [DatabaseConfiguration? config]) Future<AsyncDatabase>
Opens a Couchbase Lite database with the given name and config, which executes in a separate worker isolate.
openSync(String name, [DatabaseConfiguration? config]) SyncDatabase
Opens a Couchbase Lite database with the given name and config, which executes in the current isolate.
remove(String name, {String? directory}) Future<void>
Deletes a database of the given name in the given directory.
removeSync(String name, {String? directory}) → void
Deletes a database of the given name in the given directory.