LiteCore
Couchbase Lite cross-platform core implementation
Loading...
Searching...
No Matches
c4Database.h File Reference
#include "c4DatabaseTypes.h"

Go to the source code of this file.

Macros

#define kC4InfoStore   C4STR("info")
 
#define kC4LocalDocStore   C4STR("_local")
 

Functions

NODISCARD CBL_CORE_API C4RawDocumentc4raw_get (C4Database *database, C4String storeName, C4String docID, C4Error *outError)
 Reads a raw document from the database.
 
NODISCARD CBL_CORE_API bool c4raw_put (C4Database *database, C4String storeName, C4String key, C4String meta, C4String body, C4Error *outError)
 Writes a raw document to the database, or deletes it if both meta and body are NULL.
 
Configuration
NODISCARD CBL_CORE_API bool c4key_setPassword (C4EncryptionKey *encryptionKey, C4String password, C4EncryptionAlgorithm alg)
 Stores a password into a C4EncryptionKey, by using the key-derivation algorithm PBKDF2 to securely convert the password into a raw binary key.
 
NODISCARD CBL_CORE_API bool c4key_setPasswordSHA1 (C4EncryptionKey *encryptionKey, C4String password, C4EncryptionAlgorithm alg)
 Stores a password into a C4EncryptionKey, by using the key-derivation algorithm PBKDF2 to securely convert the password into a raw binary key.
 
CBL_CORE_API void c4_setExtensionPath (C4String path)
 
CBL_CORE_API bool c4_enableExtension (C4String name, C4String extensionPath, C4Error *outError)
 Asks LiteCore to look for and validate the presence of an extension given the name of the extension and the path in which it is supposed to reside.
 
Lifecycle
CBL_CORE_API bool c4db_exists (C4String name, C4String inDirectory)
 Returns true if a database with the given name exists in the directory.
 
NODISCARD CBL_CORE_API C4Databasec4db_openNamed (C4String name, const C4DatabaseConfig2 *config, C4Error *outError)
 Opens a database given its name (without the ".cblite2" extension) and directory.
 
NODISCARD CBL_CORE_API C4Databasec4db_openAgain (C4Database *db, C4Error *outError)
 Opens a new handle to the same database file as db.
 
NODISCARD CBL_CORE_API bool c4db_copyNamed (C4String sourcePath, C4String destinationName, const C4DatabaseConfig2 *config, C4Error *error)
 Copies a prebuilt database from the given source path and places it in the destination directory, with the given name.
 
NODISCARD CBL_CORE_API bool c4db_close (C4Database *database, C4Error *outError)
 Closes the database.
 
NODISCARD CBL_CORE_API bool c4db_delete (C4Database *database, C4Error *outError)
 Closes the database and deletes the file/bundle.
 
NODISCARD CBL_CORE_API bool c4db_deleteNamed (C4String dbName, C4String inDirectory, C4Error *outError)
 Deletes the file(s) for the database with the given name in the given directory.
 
NODISCARD CBL_CORE_API bool c4db_rekey (C4Database *database, const C4EncryptionKey *newKey, C4Error *outError)
 Changes a database's encryption key (removing encryption if it's NULL.)
 
NODISCARD CBL_CORE_API bool c4_shutdown (C4Error *outError)
 Closes down the storage engines.
 
Accessors
CBL_CORE_API C4String c4db_getName (C4Database *)
 Returns the name of the database, as given to c4db_openNamed.
 
CBL_CORE_API C4StringResult c4db_getPath (C4Database *)
 Returns the path of the database.
 
CBL_CORE_API const C4DatabaseConfig2c4db_getConfig2 (C4Database *database)
 Returns the configuration the database was opened with.
 
CBL_CORE_API uint64_t c4db_getDocumentCount (C4Database *database)
 Returns the number of (undeleted) documents in the database.
 
CBL_CORE_API C4SequenceNumber c4db_getLastSequence (C4Database *database)
 Returns the latest sequence number allocated to a revision.
 
CBL_CORE_API C4Timestamp c4db_nextDocExpiration (C4Database *database)
 Returns the timestamp at which the next document expiration should take place, or 0 if there are no documents with expiration times.
 
NODISCARD CBL_CORE_API int64_t c4db_purgeExpiredDocs (C4Database *db, C4Error *)
 Purges all documents that have expired.
 
NODISCARD CBL_CORE_API bool c4db_getUUIDs (C4Database *database, C4UUID *publicUUID, C4UUID *privateUUID, C4Error *outError)
 Returns the database's public and/or private UUIDs.
 
CBL_CORE_API void c4db_setExtraInfo (C4Database *database, C4ExtraInfo)
 Associates an arbitrary pointer with this database instance, for client use.
 
CBL_CORE_API C4ExtraInfo c4db_getExtraInfo (C4Database *database)
 Returns the C4ExtraInfo associated with this db reference.
 
Database Maintenance
NODISCARD CBL_CORE_API bool c4db_maintenance (C4Database *database, C4MaintenanceType type, C4Error *outError)
 Performs database maintenance.
 
Transactions
NODISCARD CBL_CORE_API bool c4db_beginTransaction (C4Database *database, C4Error *outError)
 Begins a transaction.
 
NODISCARD CBL_CORE_API bool c4db_endTransaction (C4Database *database, bool commit, C4Error *outError)
 Commits or aborts a transaction.
 
CBL_CORE_API bool c4db_isInTransaction (C4Database *database)
 Is a transaction active?