LiteCore
Couchbase Lite cross-platform core implementation
Loading...
Searching...
No Matches
Data Structures | Enumerations | Functions | Variables
Document Enumeration

Data Structures

struct  C4EnumeratorOptions
 Options for enumerating over all documents. More...
 
struct  C4DocumentInfo
 Metadata about a document (actually about its current revision.) More...
 

Enumerations

enum  C4EnumeratorFlags : uint16_t {
  kC4Descending = 0x01 , kC4Unsorted = 0x02 , kC4IncludeDeleted = 0x08 , kC4IncludeNonConflicted = 0x10 ,
  kC4IncludeBodies = 0x20 , kC4IncludeRevHistory = 0x40
}
 

Functions

void c4enum_close (C4DocEnumerator *e)
 Closes an enumeration.
 
NODISCARD CBL_CORE_API C4DocEnumeratorc4db_enumerateChanges (C4Database *database, C4SequenceNumber since, const C4EnumeratorOptions *options, C4Error *outError)
 Creates an enumerator ordered by sequence.
 
NODISCARD CBL_CORE_API C4DocEnumeratorc4db_enumerateAllDocs (C4Database *database, const C4EnumeratorOptions *options, C4Error *outError)
 Creates an enumerator ordered by docID.
 
NODISCARD CBL_CORE_API C4DocEnumeratorc4coll_enumerateChanges (C4Collection *collection, C4SequenceNumber since, const C4EnumeratorOptions *options, C4Error *outError)
 Creates an enumerator ordered by sequence.
 
NODISCARD CBL_CORE_API C4DocEnumeratorc4coll_enumerateAllDocs (C4Collection *collection, const C4EnumeratorOptions *options, C4Error *outError)
 Creates an enumerator ordered by docID.
 
NODISCARD CBL_CORE_API bool c4enum_next (C4DocEnumerator *e, C4Error *outError)
 Advances the enumerator to the next document.
 
NODISCARD CBL_CORE_API C4Documentc4enum_getDocument (C4DocEnumerator *e, C4Error *outError)
 Returns the current document, if any, from an enumerator.
 
CBL_CORE_API bool c4enum_getDocumentInfo (C4DocEnumerator *e, C4DocumentInfo *outInfo)
 Stores the metadata of the enumerator's current document into the supplied C4DocumentInfo struct.
 

Variables

CBL_CORE_API const C4EnumeratorOptions kC4DefaultEnumeratorOptions
 Default all-docs enumeration options.
 

Detailed Description

Enumeration Type Documentation

◆ C4EnumeratorFlags

enum C4EnumeratorFlags : uint16_t
Enumerator
kC4Descending 

If true, iteration goes by descending document IDs.

kC4Unsorted 

If true, iteration order is undefined (may be faster!)

kC4IncludeDeleted 

If true, include deleted documents.

kC4IncludeNonConflicted 

If false, include only documents in conflict.

kC4IncludeBodies 
kC4IncludeRevHistory 

If false, document bodies will not be preloaded, just metadata (docID, revID, sequence, flags.) This is faster if you don't need to access the revision tree or revision bodies.

You can still access all the data of the document, but it will trigger loading the document body from the database. Put entire revision history/version vector in revID

Function Documentation

◆ c4coll_enumerateAllDocs()

NODISCARD CBL_CORE_API C4DocEnumerator * c4coll_enumerateAllDocs ( C4Collection collection,
const C4EnumeratorOptions options,
C4Error outError 
)

Creates an enumerator ordered by docID.

Options have the same meanings as in Couchbase Lite. There's no 'limit' option; just stop enumerating when you're done. Caller is responsible for freeing the enumerator when finished with it.

Parameters
collectionThe collection.
optionsEnumeration options (NULL for defaults).
outErrorError will be stored here on failure.
Returns
A new enumerator, or NULL on failure.

◆ c4coll_enumerateChanges()

NODISCARD CBL_CORE_API C4DocEnumerator * c4coll_enumerateChanges ( C4Collection collection,
C4SequenceNumber  since,
const C4EnumeratorOptions options,
C4Error outError 
)

Creates an enumerator ordered by sequence.

Caller is responsible for freeing the enumerator when finished with it.

Parameters
collectionThe collection.
sinceThe sequence number to start after. Pass 0 to start from the beginning.
optionsEnumeration options (NULL for defaults).
outErrorError will be stored here on failure.
Returns
A new enumerator, or NULL on failure.

◆ c4db_enumerateAllDocs()

NODISCARD CBL_CORE_API C4DocEnumerator * c4db_enumerateAllDocs ( C4Database database,
const C4EnumeratorOptions options,
C4Error outError 
)

Creates an enumerator ordered by docID.

Options have the same meanings as in Couchbase Lite. There's no 'limit' option; just stop enumerating when you're done. Caller is responsible for freeing the enumerator when finished with it.

Parameters
databaseThe database.
optionsEnumeration options (NULL for defaults).
outErrorError will be stored here on failure.
Returns
A new enumerator, or NULL on failure.

◆ c4db_enumerateChanges()

NODISCARD CBL_CORE_API C4DocEnumerator * c4db_enumerateChanges ( C4Database database,
C4SequenceNumber  since,
const C4EnumeratorOptions options,
C4Error outError 
)

Creates an enumerator ordered by sequence.

Caller is responsible for freeing the enumerator when finished with it.

Parameters
databaseThe database.
sinceThe sequence number to start after. Pass 0 to start from the beginning.
optionsEnumeration options (NULL for defaults).
outErrorError will be stored here on failure.
Returns
A new enumerator, or NULL on failure.

◆ c4enum_close()

void c4enum_close ( C4DocEnumerator e)

Closes an enumeration.

This is optional, but can be used to free up resources if the enumeration has not reached its end, but will not be freed for a while.

◆ c4enum_getDocument()

NODISCARD CBL_CORE_API C4Document * c4enum_getDocument ( C4DocEnumerator e,
C4Error outError 
)

Returns the current document, if any, from an enumerator.

Parameters
eThe enumerator.
outErrorError will be stored here on failure.
Returns
The document, or NULL if there is none or if an error occurred reading its body. Caller is responsible for calling c4doc_release() when done with it.

◆ c4enum_getDocumentInfo()

CBL_CORE_API bool c4enum_getDocumentInfo ( C4DocEnumerator e,
C4DocumentInfo outInfo 
)

Stores the metadata of the enumerator's current document into the supplied C4DocumentInfo struct.

Unlike c4enum_getDocument(), this allocates no memory.

Parameters
eThe enumerator.
outInfoA pointer to a C4DocumentInfo struct that will be filled in if a document is found.
Returns
True if the info was stored, false if there is no current document.

◆ c4enum_next()

NODISCARD CBL_CORE_API bool c4enum_next ( C4DocEnumerator e,
C4Error outError 
)

Advances the enumerator to the next document.

Returns false at the end, or on error; look at the C4Error to determine which occurred, and don't forget to free the enumerator.

Variable Documentation

◆ kC4DefaultEnumeratorOptions

CBL_CORE_API const C4EnumeratorOptions kC4DefaultEnumeratorOptions
extern

Default all-docs enumeration options.

(Equal to kC4IncludeNonConflicted | kC4IncludeBodies)