Create or Open Database
You can create a new database and-or open an existing database, using the
Database class. The database class provides both synchronous and
asynchronous methods for opening and closing databases (see
explanation for Synchronous and Asynchronous APIs).
Just pass in a database name and optionally a
DatabaseConfiguration - see
Things to watch for include:
If the named database does not exist in the specified, or default, location then a new one is created.
The database is created in a default location unless you specify a directory for it — see:
Best Practice is to always specify the path to the database explicitly.
See Supported Platforms for the default location for each platform.
You are advised to incorporate the closing of all open database into your application workflow.
This feature is an Enterprise Edition feature.
Couchbase Lite includes the ability to encrypt Couchbase Lite databases. This allows mobile applications to secure data at rest, when it is being stored on the device. The algorithm used to encrypt the database is 256-bit AES.
An encrypted database can only be opened with the same language SDK that was used to encrypt it in the first place. So a database encrypted using the Dart SDK, and then exported, is readable only by the Dart or C SDK.
To change an existing encryption key, open the database using its existing
encryption-key and use
Database.changeEncryptionKey to set the required
new encryption-key value.
To remove encryption, open the database using its existing encryption-key and
Database.changeEncryptionKey with a
null value as the encryption
From time to time it may be necessary to perform certain maintenance activities on your database, for example to compact the database file, removing unused documents and blobs no longer referenced by any documents.
This is a resource intensive operation and is not performed automatically. It should be run on-demand using the API. If in doubt, consult Couchbase support.
Command Line Tool
cblite is a command-line tool for inspecting and querying Couchbase Lite databases.
Couchbase Lite for VSCode
Couchbase Lite for VSCode is a Visual Studio Code extension that provides a user interface for inspecting and querying Couchbase Lite databases. You can find more information about this extension from it's GitHub repository.
You should use console logs as your first source of diagnostic information. If
the information in the default logging level is insufficient you can focus it on
database errors and generate more verbose messages (see
— see: Example 4.