An optional interface type that improves type-safety of collection and document accessors. Its keys must be the names of the collections, and each value type is an interface that describes the properties of a document in that collection:
interface MySchema {
shoes: {style: string, foot: "left" | "right", size: number},
}
If you don't give a schema, the collections property will accept any string as a key,
and collections will use CBLDictionary as their document type.
The names of the Collections in this Database.
An object whose keys are collection names and values are Collections. In TypeScript, this object is typed accoring to the database's schema type, so accessing a nonexistent collection will result in a compile error, and Collection instances access from this will be typed according to their document schema.
True if the database is open.
Allows Database to be used with the using statement:
{
using db = new Database(config);
// `db` will be closed implicitly when it exits scope
}
See: https://www.totaltypescript.com/typescript-5-2-new-keyword-using
Encrypts or decrypts a database, or changes the encryption key.
The new password for encryption, or undefined to decrypt.
OptionalexceptProperties: UnencryptedPropertiesOptional top-level properties to leave unencrypted, by collection (in addition to indexed properties, which cannot be encrypted.) Key is collection name, value is array or set of properties.
Closes the database.
You MUST NOT call any instance methods after this except for reopen.
You MUST NOT use or keep reference to the Database's Collections; they're invalidated.
Closes the database, then deletes its persistent storage.
Note: You can call reopen, and have an empty database.
Returns the number of blobs stored in the database.
Decrypts the database. (Same as encrypt(undefined).)
Deletes all blobs that are no longer referenced by any documents.
The number of blobs deleted.
Reopens the database after a close or closeAndDelete call.
Optionalpassword: stringIf the database is encrypted, you must provide the password.
StaticdebugEnable's Dexie's debug mode, which provides meaningful stack backtraces in exceptions.
StaticdeleteStatic method that deletes a database by name. You MUST close any open Database instance using it first.
StaticopenCreates a Database instance and opens the database. If a local IndexedDB database with this name exists, it will be opened; otherwise a new one is created.
An optional interface type that improves type-safety of collection and document accessors. Its keys must be the names of the collections, and each value type is an interface that describes the properties of a document in that collection.
The database configuration
StaticuseCall this to use a non-default implementation of IndexedDB. This is required in non-browser environments like Node, Bun and Deno! It should be called only once, before creating any Database objects. Example:
import { indexedDB, IDBKeyRange } from "fake-indexeddb";
Database.useIndexedDB(indexedDB, IDBKeyRange);
The bound() static method of the IDBKeyRange interface creates a new key range with the specified upper and lower bounds.
OptionallowerOpen: booleanOptionalupperOpen: booleanThe lowerBound() static method of the By default, it includes the lower endpoint value and is closed.
Optionalopen: booleanThe only() static method of the IDBKeyRange interface creates a new key range containing a single value.
The upperBound() static method of the it includes the upper endpoint value and is closed.
Optionalopen: boolean
A Couchbase Lite database. Contains one or more named collections, which contain documents.
Call open to create a Database instance (the constructor is private.)