Couchbase Lite C
Couchbase Lite C API
|
#include "CBLBase.h"
Go to the source code of this file.
Functions | |
Mutable documents | |
The type A mutable document exposes its properties as a mutable dictionary, so you can change them in place and then call CBLDatabase_SaveDocument to persist the changes. | |
_cbl_warn_unused CBLDocument *_cbl_nullable | CBLDatabase_GetMutableDocument (CBLDatabase *database, FLString docID, CBLError *_cbl_nullable outError) |
Reads a document from the default collection in mutable form that can be updated and saved. More... | |
_cbl_warn_unused CBLDocument * | CBLDocument_Create (void) |
Creates a new, empty document in memory, with a randomly-generated unique ID. More... | |
_cbl_warn_unused CBLDocument * | CBLDocument_CreateWithID (FLString docID) |
Creates a new, empty document in memory, with the given ID. More... | |
_cbl_warn_unused CBLDocument * | CBLDocument_MutableCopy (const CBLDocument *original) |
Creates a new mutable CBLDocument instance that refers to the same document as the original. More... | |
Document properties and metadata | |
A document's body is essentially a JSON object. The properties are accessed in memory using the Fleece API, with the body itself being a dictionary). | |
FLString | CBLDocument_ID (const CBLDocument *) |
Returns a document's ID. More... | |
FLString | CBLDocument_RevisionID (const CBLDocument *) |
Returns a document's revision ID, which is a short opaque string that's guaranteed to be unique to every change made to the document. More... | |
uint64_t | CBLDocument_Sequence (const CBLDocument *) |
Returns a document's current sequence in the local database. More... | |
CBLCollection *_cbl_nullable | CBLDocument_Collection (const CBLDocument *) |
Returns a document's collection or NULL for the new document that hasn't been saved. More... | |
FLDict | CBLDocument_Properties (const CBLDocument *) |
Returns a document's properties as a dictionary. More... | |
FLMutableDict | CBLDocument_MutableProperties (CBLDocument *) |
Returns a mutable document's properties as a mutable dictionary. More... | |
void | CBLDocument_SetProperties (CBLDocument *, FLMutableDict properties) |
Sets a mutable document's properties. More... | |
_cbl_warn_unused FLSliceResult | CBLDocument_CreateJSON (const CBLDocument *) |
Returns a document's properties as JSON. More... | |
bool | CBLDocument_SetJSON (CBLDocument *, FLSlice json, CBLError *_cbl_nullable outError) |
Sets a mutable document's properties from a JSON string. More... | |
CBLTimestamp | CBLDatabase_GetDocumentExpiration (CBLDatabase *db, FLSlice docID, CBLError *_cbl_nullable outError) |
Returns the time, if any, at which a given document will expire and be purged. More... | |
bool | CBLDatabase_SetDocumentExpiration (CBLDatabase *db, FLSlice docID, CBLTimestamp expiration, CBLError *_cbl_nullable outError) |
Sets or clears the expiration time of a document. More... | |
Variables | |
CBL_PUBLIC const FLSlice | kCBLTypeProperty |
"@type" More... | |
Document lifecycle | |
enum | CBLConcurrencyControl : uint8_t { kCBLConcurrencyControlLastWriteWins , kCBLConcurrencyControlFailOnConflict } |
Conflict-handling options when saving or deleting a document. More... | |
typedef bool(* | CBLConflictHandler) (void *_cbl_nullable context, CBLDocument *_cbl_nullable documentBeingSaved, const CBLDocument *_cbl_nullable conflictingDocument) |
Custom conflict handler for use when saving or deleting a document. More... | |
_cbl_warn_unused const CBLDocument *_cbl_nullable | CBLDatabase_GetDocument (const CBLDatabase *database, FLString docID, CBLError *_cbl_nullable outError) |
Reads a document from the default collection in an immutable form. More... | |
static const CBLDocument * | CBLDocument_Retain (const CBLDocument *t) |
static void | CBLDocument_Release (const CBLDocument *t) |
bool | CBLDatabase_SaveDocument (CBLDatabase *db, CBLDocument *doc, CBLError *_cbl_nullable outError) |
Saves a (mutable) document to the default collection. More... | |
bool | CBLDatabase_SaveDocumentWithConcurrencyControl (CBLDatabase *db, CBLDocument *doc, CBLConcurrencyControl concurrency, CBLError *_cbl_nullable outError) |
Saves a (mutable) document to the default collection. More... | |
bool | CBLDatabase_SaveDocumentWithConflictHandler (CBLDatabase *db, CBLDocument *doc, CBLConflictHandler conflictHandler, void *_cbl_nullable context, CBLError *_cbl_nullable outError) |
Saves a (mutable) document to the default collection, allowing for custom conflict handling in the event that the document has been updated since doc was loaded. More... | |
bool | CBLDatabase_DeleteDocument (CBLDatabase *db, const CBLDocument *document, CBLError *_cbl_nullable outError) |
Deletes a document from the default collection. More... | |
bool | CBLDatabase_DeleteDocumentWithConcurrencyControl (CBLDatabase *db, const CBLDocument *document, CBLConcurrencyControl concurrency, CBLError *_cbl_nullable outError) |
Deletes a document from the default collection. More... | |
bool | CBLDatabase_PurgeDocument (CBLDatabase *db, const CBLDocument *document, CBLError *_cbl_nullable outError) |
Purges a document from the default collection. More... | |
bool | CBLDatabase_PurgeDocumentByID (CBLDatabase *database, FLString docID, CBLError *_cbl_nullable outError) |
Purges a document by its ID from the default collection. More... | |
Document listeners | |
A document change listener lets you detect changes made to a specific document after they are persisted to the database.
| |
typedef void(* | CBLDocumentChangeListener) (void *context, const CBLDatabase *db, FLString docID) |
A document change listener callback, invoked after a specific document is changed on disk. More... | |
_cbl_warn_unused CBLListenerToken * | CBLDatabase_AddDocumentChangeListener (const CBLDatabase *db, FLString docID, CBLDocumentChangeListener listener, void *_cbl_nullable context) |
Registers a document change listener callback. More... | |