Couchbase Lite C
Couchbase Lite C API
CBLCollection.h
Go to the documentation of this file.
1//
2// CBLCollection.h
3//
4// Copyright (c) 2022 Couchbase, Inc All rights reserved.
5//
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17//
18
19#pragma once
20#include "CBLBase.h"
21#include "CBLDocument.h"
22#include "CBLQueryIndexTypes.h"
23#include "CBLQueryTypes.h"
24
26
67
74
83 CBLError* _cbl_nullable outError) CBLAPI;
84
92 FLString scopeName,
93 CBLError* _cbl_nullable outError) CBLAPI;
94
104 FLString scopeName,
105 CBLError* _cbl_nullable outError) CBLAPI;
106
115 FLString collectionName,
116 FLString scopeName,
117 CBLError* _cbl_nullable outError) CBLAPI;
118
133 FLString collectionName,
134 FLString scopeName,
135 CBLError* _cbl_nullable outError) CBLAPI;
136
145 FLString collectionName,
146 FLString scopeName,
147 CBLError* _cbl_nullable outError) CBLAPI;
148
155 CBLError* _cbl_nullable outError) CBLAPI;
156
163 CBLError* _cbl_nullable outError) CBLAPI;
164
177
182
187
193
197uint64_t CBLCollection_Count(const CBLCollection* collection) CBLAPI;
198
215 FLString docID,
216 CBLError* _cbl_nullable outError) CBLAPI;
217
228 CBLDocument* doc,
229 CBLError* _cbl_nullable outError) CBLAPI;
230
242 CBLDocument* doc,
243 CBLConcurrencyControl concurrency,
244 CBLError* _cbl_nullable outError) CBLAPI;
245
255 CBLDocument* doc,
256 CBLConflictHandler conflictHandler,
257 void* _cbl_nullable context,
258 CBLError* _cbl_nullable outError) CBLAPI;
259
267 const CBLDocument* document,
268 CBLError* _cbl_nullable outError) CBLAPI;
269
278 const CBLDocument* document,
279 CBLConcurrencyControl concurrency,
280 CBLError* _cbl_nullable outError) CBLAPI;
281
293 const CBLDocument* document,
294 CBLError* _cbl_nullable outError) CBLAPI;
295
304 FLString docID,
305 CBLError* _cbl_nullable outError) CBLAPI;
306
317 FLSlice docID,
318 CBLError* _cbl_nullable outError) CBLAPI;
319
328 FLSlice docID,
329 CBLTimestamp expiration,
330 CBLError* _cbl_nullable outError) CBLAPI;
350 FLString docID,
351 CBLError* _cbl_nullable outError) CBLAPI;
367 FLString name,
369 CBLError* _cbl_nullable outError) CBLAPI;
370
380 FLString name,
382 CBLError* _cbl_nullable outError) CBLAPI;
383
384#ifdef COUCHBASE_ENTERPRISE
392 FLString name,
394 CBLError* _cbl_nullable outError) CBLAPI;
395
396#endif
397
404 FLString name,
405 CBLError* _cbl_nullable outError) CBLAPI;
406
414 CBLError* _cbl_nullable outError) CBLAPI;
415
424 FLString name,
425 CBLError* _cbl_nullable outError) CBLAPI;
426
437typedef struct {
439 unsigned numDocs;
442
449typedef void (*CBLCollectionChangeListener)(void* _cbl_nullable context,
450 const CBLCollectionChange* change);
451
460 void* _cbl_nullable context) CBLAPI;
461
473typedef struct {
477
484typedef void (*CBLCollectionDocumentChangeListener)(void *context, const CBLDocumentChange* change);
485
494 FLString docID,
496 void* _cbl_nullable context) CBLAPI;
497 // end of outer \defgroup
500
#define CBLAPI
Definition: CBL_Compat.h:104
#define _cbl_nullable
Definition: CBL_Compat.h:92
#define CBL_CAPI_BEGIN
Definition: CBL_Compat.h:105
#define CBL_CAPI_END
Definition: CBL_Compat.h:106
#define CBL_PUBLIC
Definition: CBL_Compat.h:123
#define _cbl_warn_unused
Definition: CBL_Compat.h:40
CBLCollection *_cbl_nullable CBLDatabase_DefaultCollection(const CBLDatabase *db, CBLError *_cbl_nullable outError)
Returns the default collection.
_cbl_warn_unused FLMutableArray _cbl_nullable CBLCollection_GetIndexNames(CBLCollection *collection, CBLError *_cbl_nullable outError)
Returns the names of the indexes in the collection, as a Fleece array of strings.
void(* CBLCollectionChangeListener)(void *_cbl_nullable context, const CBLCollectionChange *change)
A collection change listener callback, invoked after one or more documents are changed on disk.
Definition: CBLCollection.h:449
bool CBLCollection_SetDocumentExpiration(CBLCollection *collection, FLSlice docID, CBLTimestamp expiration, CBLError *_cbl_nullable outError)
Sets or clears the expiration time of a document.
uint64_t CBLCollection_Count(const CBLCollection *collection)
Returns the number of documents in the collection.
bool CBLCollection_DeleteDocumentWithConcurrencyControl(CBLCollection *collection, const CBLDocument *document, CBLConcurrencyControl concurrency, CBLError *_cbl_nullable outError)
Deletes a document from the collection.
bool CBLCollection_PurgeDocument(CBLCollection *collection, const CBLDocument *document, CBLError *_cbl_nullable outError)
Purges a document.
CBL_PUBLIC const FLString kCBLDefaultCollectionName
The default collection's name.
bool CBLCollection_CreateVectorIndex(CBLCollection *collection, FLString name, CBLVectorIndexConfiguration config, CBLError *_cbl_nullable outError)
ENTERPRISE EDITION ONLY.
bool CBLCollection_DeleteIndex(CBLCollection *collection, FLString name, CBLError *_cbl_nullable outError)
Deletes an index in the collection by name.
bool CBLDatabase_DeleteCollection(CBLDatabase *db, FLString collectionName, FLString scopeName, CBLError *_cbl_nullable outError)
Delete an existing collection.
_cbl_warn_unused CBLQueryIndex *_cbl_nullable CBLCollection_GetIndex(CBLCollection *collection, FLString name, CBLError *_cbl_nullable outError)
Returns an index object representing an existing index in the collection.
bool CBLCollection_CreateValueIndex(CBLCollection *collection, FLString name, CBLValueIndexConfiguration config, CBLError *_cbl_nullable outError)
Creates a value index in the collection.
CBLDatabase * CBLCollection_Database(const CBLCollection *collection)
Returns the collection's database.
bool CBLCollection_SaveDocument(CBLCollection *collection, CBLDocument *doc, CBLError *_cbl_nullable outError)
Saves a (mutable) document to the collection.
CBLCollection *_cbl_nullable CBLDatabase_Collection(const CBLDatabase *db, FLString collectionName, FLString scopeName, CBLError *_cbl_nullable outError)
Returns the existing collection with the given name and scope.
bool CBLCollection_CreateFullTextIndex(CBLCollection *collection, FLString name, CBLFullTextIndexConfiguration config, CBLError *_cbl_nullable outError)
Creates a full-text index in the collection.
bool CBLCollection_DeleteDocument(CBLCollection *collection, const CBLDocument *document, CBLError *_cbl_nullable outError)
Deletes a document from the collection.
bool CBLCollection_PurgeDocumentByID(CBLCollection *collection, FLString docID, CBLError *_cbl_nullable outError)
Purges a document, given only its ID.
_cbl_warn_unused CBLListenerToken * CBLCollection_AddChangeListener(const CBLCollection *collection, CBLCollectionChangeListener listener, void *_cbl_nullable context)
Registers a collection change listener callback.
_cbl_warn_unused const CBLDocument *_cbl_nullable CBLCollection_GetDocument(const CBLCollection *collection, FLString docID, CBLError *_cbl_nullable outError)
Reads a document from the collection, creating a new (immutable) CBLDocument object.
CBLScope *_cbl_nullable CBLDatabase_Scope(const CBLDatabase *db, FLString scopeName, CBLError *_cbl_nullable outError)
Returns an existing scope with the given name.
CBLCollection *_cbl_nullable CBLDatabase_CreateCollection(CBLDatabase *db, FLString collectionName, FLString scopeName, CBLError *_cbl_nullable outError)
Create a new collection.
FLMutableArray _cbl_nullable CBLDatabase_CollectionNames(const CBLDatabase *db, FLString scopeName, CBLError *_cbl_nullable outError)
Returns the names of all collections in the scope.
CBLScope * CBLDatabase_DefaultScope(const CBLDatabase *db, CBLError *_cbl_nullable outError)
Returns the default scope.
_cbl_warn_unused CBLDocument *_cbl_nullable CBLCollection_GetMutableDocument(CBLCollection *collection, FLString docID, CBLError *_cbl_nullable outError)
Reads a document from the collection, in mutable form that can be updated and saved.
_cbl_warn_unused CBLListenerToken * CBLCollection_AddDocumentChangeListener(const CBLCollection *collection, FLString docID, CBLCollectionDocumentChangeListener listener, void *_cbl_nullable context)
Registers a document change listener callback.
FLString CBLCollection_Name(const CBLCollection *collection)
Returns the collection's name.
FLMutableArray _cbl_nullable CBLDatabase_ScopeNames(const CBLDatabase *db, CBLError *_cbl_nullable outError)
Returns the names of all existing scopes in the database.
bool CBLCollection_SaveDocumentWithConflictHandler(CBLCollection *collection, CBLDocument *doc, CBLConflictHandler conflictHandler, void *_cbl_nullable context, CBLError *_cbl_nullable outError)
Saves a (mutable) document to the collection, allowing for custom conflict handling in the event that...
CBLScope * CBLCollection_Scope(const CBLCollection *collection)
Returns the collection's scope.
bool CBLCollection_SaveDocumentWithConcurrencyControl(CBLCollection *collection, CBLDocument *doc, CBLConcurrencyControl concurrency, CBLError *_cbl_nullable outError)
Saves a (mutable) document to the collection.
struct CBLCollection CBLCollection
A collection, a document container.
Definition: CBLBase.h:194
CBLTimestamp CBLCollection_GetDocumentExpiration(CBLCollection *collection, FLSlice docID, CBLError *_cbl_nullable outError)
Returns the time, if any, at which a given document will expire and be purged.
void(* CBLCollectionDocumentChangeListener)(void *context, const CBLDocumentChange *change)
A document change listener callback, invoked after a specific document is changed on disk.
Definition: CBLCollection.h:484
FLString CBLCollection_FullName(const CBLCollection *collection)
Returns the collection's fully qualified name in the '<scope-name>.
struct CBLDatabase CBLDatabase
A connection to an open database.
Definition: CBLBase.h:182
CBLConcurrencyControl
Conflict-handling options when saving or deleting a document.
Definition: CBLDocument.h:35
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.
Definition: CBLDocument.h:56
struct CBLDocument CBLDocument
An in-memory copy of a document.
Definition: CBLBase.h:203
struct CBLQueryIndex CBLQueryIndex
A query index.
Definition: CBLBase.h:224
struct CBLListenerToken CBLListenerToken
An opaque 'cookie' representing a registered listener callback.
Definition: CBLBase.h:281
int64_t CBLTimestamp
A date/time representation used for document expiration (and in date/time queries....
Definition: CBLBase.h:123
#define CBL_REFCOUNTED(TYPE, NAME)
Definition: CBLBase.h:170
struct CBLScope CBLScope
A collection's scope.
Definition: CBLBase.h:188
struct _FLArray * FLMutableArray
A reference to a mutable array.
Definition: FLBase.h:39
Definition: CBLCollection.h:437
FLString * docIDs
The IDs of the documents that changed.
Definition: CBLCollection.h:440
unsigned numDocs
The number of documents that changed (size of the docIDs array).
Definition: CBLCollection.h:439
const CBLCollection * collection
The collection that changed.
Definition: CBLCollection.h:438
Definition: CBLCollection.h:473
const CBLCollection * collection
The collection that changed.
Definition: CBLCollection.h:474
FLString docID
The document's ID.
Definition: CBLCollection.h:475
A struct holding information about an error.
Definition: CBLBase.h:104
Full-Text Index Configuration.
Definition: CBLQueryIndexTypes.h:42
Value Index Configuration.
Definition: CBLQueryIndexTypes.h:32
ENTERPRISE EDITION ONLY.
Definition: CBLQueryIndexTypes.h:113
A simple reference to a block of memory.
Definition: FLSlice.h:45