LiteCore
Couchbase Lite cross-platform core implementation
Loading...
Searching...
No Matches
c4Collection.h
Go to the documentation of this file.
1//
2// c4Collection.h
3//
4// Copyright 2021-Present Couchbase, Inc.
5//
6// Use of this software is governed by the Business Source License included
7// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified
8// in that file, in accordance with the Business Source License, use of this
9// software will be governed by the Apache License, Version 2.0, included in
10// the file licenses/APL2.txt.
11//
12
13#pragma once
14#include "c4DatabaseTypes.h"
15#include "c4DocumentTypes.h"
16#include "fleece/Fleece.h"
17
20
21
22/* NOTE:
23 Enumeration-related functions are in c4DocEnumerator.h:
24 - c4coll_enumerateChanges
25 - c4coll_enumerateAllDocs
26 Observer-related functions are in c4Observer.h:
27 - c4dbobs_createOnCollection
28 - c4docobs_createWithCollection
29 Index-related functions are in c4Index.h:
30 - c4coll_createIndex
31 - c4coll_deleteIndex
32 - c4coll_getIndex
33 - c4coll_getIndexesInfo
34*/
35
36
109
113
117
122 C4Error* C4NULLABLE outError) C4API;
123
130 C4Error* C4NULLABLE outError) C4API;
131
137 C4Error* C4NULLABLE outError) C4API;
138
144 C4Error* C4NULLABLE outError) C4API;
145
150
151
160
164
168
172
176
177
195 C4DocContentLevel content,
196 C4Error* C4NULLABLE outError) C4API;
197
202 C4Error* C4NULLABLE outError) C4API;
203
217 size_t* C4NULLABLE outCommonAncestorIndex,
218 C4Error* C4NULLABLE outError) C4API;
219
231 C4RevisionFlags revisionFlags,
232 C4Error* C4NULLABLE error) C4API;
233
243 C4String newDocID, C4Error* C4NULLABLE error) C4API;
244
245
247
248
257 C4Error* C4NULLABLE outError) C4API;
258
259
270 C4Error* C4NULLABLE outError) C4API;
271
281 C4Error* C4NULLABLE outError) C4API;
282
287
292
293
295 // end Collections group
296
297
#define NODISCARD
Definition CompilerSupport.h:59
#define CBL_CORE_API
Definition c4Compat.h:134
#define C4NULLABLE
Definition c4Compat.h:38
#define C4API
Definition c4Compat.h:114
#define C4_ASSUME_NONNULL_BEGIN
Definition c4Compat.h:36
#define C4API_END_DECLS
Definition c4Compat.h:116
#define C4API_BEGIN_DECLS
Definition c4Compat.h:115
#define C4_ASSUME_NONNULL_END
Definition c4Compat.h:37
int64_t C4Timestamp
A date/time representation used for document expiration (and in date/time queries....
Definition c4Base.h:96
uint64_t C4SequenceNumber
A database sequence number, representing the order in which a revision was created.
Definition c4Base.h:91
struct C4Collection C4Collection
Opaque handle to a namespace of documents in an opened database.
Definition c4Base.h:126
struct C4Database C4Database
Opaque handle to an opened database.
Definition c4Base.h:136
CBL_CORE_API C4Timestamp c4coll_nextDocExpiration(C4Collection *)
Returns the time at which the next document expiration in this collection should take place,...
NODISCARD CBL_CORE_API C4Collection * c4db_createCollection(C4Database *db, C4CollectionSpec spec, C4Error *outError)
Creates and returns an empty collection with the given name & scope.
CBL_CORE_API bool c4db_hasCollection(C4Database *db, C4CollectionSpec spec)
Returns true if the collection exists.
CBL_CORE_API uint64_t c4coll_getDocumentCount(C4Collection *)
Returns the number of (undeleted) documents in the collection.
CBL_CORE_API C4Database * c4coll_getDatabase(C4Collection *)
Returns the database containing the collection, or NULL if the collection is invalid.
NODISCARD CBL_CORE_API C4Document * c4coll_createDoc(C4Collection *collection, C4String docID, C4Slice body, C4RevisionFlags revisionFlags, C4Error *error)
Convenience function to create a new document.
CBL_CORE_API C4Collection * c4db_getDefaultCollection(C4Database *db, C4Error *outError)
Returns the default collection, whose name is "`_default`" (kC4DefaultCollectionName).
CBL_CORE_API bool c4coll_isValid(C4Collection *)
Returns false if this collection has been deleted, or its database closed.
NODISCARD CBL_CORE_API C4Document * c4coll_putDoc(C4Collection *collection, const C4DocPutRequest *request, size_t *outCommonAncestorIndex, C4Error *outError)
A high-level Put operation, to insert a new or downloaded revision.
CBL_CORE_API bool c4db_hasScope(C4Database *db, C4String name)
Returns true if the named scope exists.
NODISCARD CBL_CORE_API C4Document * c4coll_getDoc(C4Collection *collection, C4String docID, bool mustExist, C4DocContentLevel content, C4Error *outError)
Gets a document from the collection given its ID.
NODISCARD CBL_CORE_API FLMutableArray c4db_collectionNames(C4Database *db, C4String inScope, C4Error *outError)
Returns the names of all existing collections in the given scope, in the order in which they were cre...
CBL_CORE_API C4CollectionSpec c4coll_getSpec(C4Collection *)
Returns the name and scope of the collection.
NODISCARD CBL_CORE_API bool c4coll_moveDoc(C4Collection *collection, C4String docID, C4Collection *toCollection, C4String newDocID, C4Error *error)
Moves a document to another collection, possibly with a different docID.
NODISCARD CBL_CORE_API bool c4coll_setDocExpiration(C4Collection *collection, C4String docID, C4Timestamp timestamp, C4Error *outError)
Sets an expiration date on a document.
NODISCARD CBL_CORE_API bool c4coll_purgeDoc(C4Collection *collection, C4String docID, C4Error *outError)
Removes all trace of a document and its revisions from the collection.
NODISCARD CBL_CORE_API FLMutableArray c4db_scopeNames(C4Database *db, C4Error *outError)
Returns the names of all existing scopes, in the order in which they were created.
CBL_CORE_API C4Timestamp c4coll_getDocExpiration(C4Collection *collection, C4String docID, C4Error *outError)
Returns the expiration time of a document, if one has been set, else 0.
NODISCARD CBL_CORE_API bool c4db_deleteCollection(C4Database *db, C4CollectionSpec spec, C4Error *outError)
Deletes the collection with the given name & scope.
NODISCARD CBL_CORE_API C4Document * c4coll_getDocBySequence(C4Collection *collection, C4SequenceNumber, C4Error *outError)
Gets a document from the collection given its sequence number.
CBL_CORE_API C4Collection * c4db_getCollection(C4Database *db, C4CollectionSpec spec, C4Error *outError)
Returns the existing collection with the given name & scope, or NULL if it doesn't exist.
NODISCARD CBL_CORE_API int64_t c4coll_purgeExpiredDocs(C4Collection *, C4Error *)
Purges all documents that have expired.
CBL_CORE_API C4SequenceNumber c4coll_getLastSequence(C4Collection *)
Returns the latest sequence number allocated to a revision.
C4DocContentLevel
Definition c4DocumentTypes.h:50
C4RevisionFlags
Definition c4DocumentTypes.h:33
struct _FLArray * FLMutableArray
A reference to a mutable array.
Definition FLBase.h:39
Full identifier of a collection in a database, including its scope.
Definition c4DatabaseTypes.h:91
Parameters for adding a revision using c4doc_put.
Definition c4DocumentTypes.h:88
Describes a version-controlled document.
Definition c4DocumentStruct.h:32
An error value.
Definition c4Error.h:133
A simple reference to a block of memory.
Definition FLSlice.h:45