Couchbase Lite C
Couchbase Lite C API
Loading...
Searching...
No Matches
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
55
57
61
64
73 CBLError* _cbl_nullable outError) CBLAPI;
74
82 FLString scopeName,
83 CBLError* _cbl_nullable outError) CBLAPI;
84
94 FLString scopeName,
95 CBLError* _cbl_nullable outError) CBLAPI;
96
105 FLString collectionName,
106 FLString scopeName,
107 CBLError* _cbl_nullable outError) CBLAPI;
108
123 FLString collectionName,
124 FLString scopeName,
125 CBLError* _cbl_nullable outError) CBLAPI;
126
135 FLString collectionName,
136 FLString scopeName,
137 CBLError* _cbl_nullable outError) CBLAPI;
138
145 CBLError* _cbl_nullable outError) CBLAPI;
146
153 CBLError* _cbl_nullable outError) CBLAPI;
154
156
161
167
172
177
183
187uint64_t CBLCollection_Count(const CBLCollection* collection) CBLAPI;
188
190
193
205 FLString docID,
206 CBLError* _cbl_nullable outError) CBLAPI;
207
218 CBLDocument* doc,
219 CBLError* _cbl_nullable outError) CBLAPI;
220
232 CBLDocument* doc,
233 CBLConcurrencyControl concurrency,
234 CBLError* _cbl_nullable outError) CBLAPI;
235
245 CBLDocument* doc,
246 CBLConflictHandler conflictHandler,
247 void* _cbl_nullable context,
248 CBLError* _cbl_nullable outError) CBLAPI;
249
257 const CBLDocument* document,
258 CBLError* _cbl_nullable outError) CBLAPI;
259
268 const CBLDocument* document,
269 CBLConcurrencyControl concurrency,
270 CBLError* _cbl_nullable outError) CBLAPI;
271
283 const CBLDocument* document,
284 CBLError* _cbl_nullable outError) CBLAPI;
285
294 FLString docID,
295 CBLError* _cbl_nullable outError) CBLAPI;
296
307 FLSlice docID,
308 CBLError* _cbl_nullable outError) CBLAPI;
309
318 FLSlice docID,
319 CBLTimestamp expiration,
320 CBLError* _cbl_nullable outError) CBLAPI;
322
329
340 FLString docID,
341 CBLError* _cbl_nullable outError) CBLAPI;
343
347
357 FLString name,
359 CBLError* _cbl_nullable outError) CBLAPI;
360
370 FLString name,
372 CBLError* _cbl_nullable outError) CBLAPI;
373
383 FLString name,
385 CBLError* _cbl_nullable outError) CBLAPI;
386
387#ifdef COUCHBASE_ENTERPRISE
395 FLString name,
397 CBLError* _cbl_nullable outError) CBLAPI;
398
399#endif
400
407 FLString name,
408 CBLError* _cbl_nullable outError) CBLAPI;
409
417 CBLError* _cbl_nullable outError) CBLAPI;
418
427 FLString name,
428 CBLError* _cbl_nullable outError) CBLAPI;
429
431
439
445
452typedef void (*CBLCollectionChangeListener)(void* _cbl_nullable context,
453 const CBLCollectionChange* change);
454
463 void* _cbl_nullable context) CBLAPI;
464
466
475
480
487typedef void (*CBLCollectionDocumentChangeListener)(void *context, const CBLDocumentChange* change);
488
497 FLString docID,
499 void* _cbl_nullable context) CBLAPI;
500 // end of outer \defgroup
503
#define CBLAPI
Definition CBL_Compat.h:105
#define _cbl_nullable
Definition CBL_Compat.h:92
#define CBL_CAPI_BEGIN
Definition CBL_Compat.h:107
#define CBL_CAPI_END
Definition CBL_Compat.h:108
#define CBL_PUBLIC
Definition CBL_Compat.h:125
#define _cbl_warn_unused
Definition CBL_Compat.h:40
FLSlice FLString
Definition FLSlice.h:98
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:452
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.
bool CBLCollection_CreateArrayIndex(CBLCollection *collection, FLString name, CBLArrayIndexConfiguration config, CBLError *_cbl_nullable outError)
Creates an array index for use with UNNEST queries in the collection.
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:195
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:487
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:183
CBLConcurrencyControl
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:55
struct CBLDocument CBLDocument
An in-memory copy of a document.
Definition CBLBase.h:204
struct CBLQueryIndex CBLQueryIndex
A query index.
Definition CBLBase.h:225
struct CBLListenerToken CBLListenerToken
An opaque 'cookie' representing a registered listener callback.
Definition CBLBase.h:284
int64_t CBLTimestamp
A date/time representation used for document expiration (and in date/time queries....
Definition CBLBase.h:124
#define CBL_REFCOUNTED(TYPE, NAME)
Definition CBLBase.h:171
struct CBLScope CBLScope
A collection's scope.
Definition CBLBase.h:189
struct _FLArray * FLMutableArray
A reference to a mutable array.
Definition FLBase.h:39
Array Index Configuration for indexing property values within arrays in documents,...
Definition CBLQueryIndexTypes.h:83
Definition CBLCollection.h:440
FLString * docIDs
The IDs of the documents that changed.
Definition CBLCollection.h:443
unsigned numDocs
The number of documents that changed (size of the docIDs array).
Definition CBLCollection.h:442
const CBLCollection * collection
The collection that changed.
Definition CBLCollection.h:441
Definition CBLCollection.h:476
const CBLCollection * collection
The collection that changed.
Definition CBLCollection.h:477
FLString docID
The document's ID.
Definition CBLCollection.h:478
A struct holding information about an error.
Definition CBLBase.h:105
Full-Text Index Configuration.
Definition CBLQueryIndexTypes.h:48
Value Index Configuration.
Definition CBLQueryIndexTypes.h:32
ENTERPRISE EDITION ONLY.
Definition CBLQueryIndexTypes.h:145
A simple reference to a block of memory.
Definition FLSlice.h:45