Couchbase Lite C
Couchbase Lite C API
Loading...
Searching...
No Matches
CBLDocument.h File Reference
#include "CBLBase.h"

Go to the source code of this file.

Functions

Mutable documents

The type CBLDocument* without a const qualifier refers to a mutable document instance.

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 CBLDocumentCBLDocument_Create (void)
 Creates a new, empty document in memory, with a randomly-generated unique ID.
_cbl_warn_unused CBLDocumentCBLDocument_CreateWithID (FLString docID)
 Creates a new, empty document in memory, with the given ID.
_cbl_warn_unused CBLDocumentCBLDocument_MutableCopy (const CBLDocument *original)
 Creates a new mutable CBLDocument instance that refers to the same document as the original.
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.
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.
uint64_t CBLDocument_Timestamp (const CBLDocument *)
 The hybrid logical timestamp in nanoseconds since epoch that the revision was created.
uint64_t CBLDocument_Sequence (const CBLDocument *)
 Returns a document's current sequence in the local database.
CBLCollection *_cbl_nullable CBLDocument_Collection (const CBLDocument *)
 Returns a document's collection or NULL for the new document that hasn't been saved.
FLDict CBLDocument_Properties (const CBLDocument *)
 Returns a document's properties as a dictionary.
FLMutableDict CBLDocument_MutableProperties (CBLDocument *)
 Returns a mutable document's properties as a mutable dictionary.
void CBLDocument_SetProperties (CBLDocument *, FLMutableDict properties)
 Sets a mutable document's properties.
_cbl_warn_unused FLSliceResult CBLDocument_CreateJSON (const CBLDocument *)
 Returns a document's properties as JSON.
bool CBLDocument_SetJSON (CBLDocument *, FLSlice json, CBLError *_cbl_nullable outError)
 Sets a mutable document's properties from a JSON string.

Variables

CBL_PUBLIC const FLSlice kCBLTypeProperty
 "@type"

Document lifecycle

enum  CBLConcurrencyControl : uint8_t { kCBLConcurrencyControlLastWriteWins , kCBLConcurrencyControlFailOnConflict }
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.
CBLINLINE const CBLDocumentCBLDocument_Retain (const CBLDocument *_cbl_nullable t)
CBLINLINE void CBLDocument_Release (const CBLDocument *_cbl_nullable t)