Couchbase Lite C
Couchbase Lite C API
CBLQuery.h
Go to the documentation of this file.
1//
2// CBLQuery.h
3//
4// Copyright (c) 2018 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 "fleece/Fleece.h"
22
24
25
43typedef CBL_ENUM(uint32_t, CBLQueryLanguage) {
46};
47
48
69 CBLQueryLanguage language,
70 FLString queryString,
71 int* _cbl_nullable outErrorPos,
72 CBLError* _cbl_nullable outError) CBLAPI;
73
75
88 FLDict parameters) CBLAPI;
89
92
99 CBLError* _cbl_nullable outError) CBLAPI;
100
109
112
120 unsigned columnIndex) CBLAPI;
121
151
156 unsigned index) CBLAPI;
157
164 FLString key) CBLAPI;
165
170
175
178
180
204typedef void (*CBLQueryChangeListener)(void* _cbl_nullable context,
205 CBLQuery* query,
206 CBLListenerToken* token);
207
221 CBLQueryChangeListener listener,
222 void* _cbl_nullable context) CBLAPI;
223
233 CBLListenerToken *listener,
234 CBLError* _cbl_nullable outError) CBLAPI;
235
267typedef struct {
270
275
281 FLString name,
283 CBLError* _cbl_nullable outError) CBLAPI;
284
285
287typedef struct {
290
294
298
312
318 FLString name,
320 CBLError* _cbl_nullable outError) CBLAPI;
321
324 FLString name,
325 CBLError* _cbl_nullable outError) CBLAPI;
326
331
#define CBLAPI
Definition: CBL_Compat.h:98
#define _cbl_nullable
Definition: CBL_Compat.h:86
#define CBL_CAPI_BEGIN
Definition: CBL_Compat.h:99
#define CBL_CAPI_END
Definition: CBL_Compat.h:100
#define CBL_ENUM(_type, _name)
Definition: CBL_Compat.h:56
#define _cbl_warn_unused
Definition: CBL_Compat.h:41
struct CBLDatabase CBLDatabase
A connection to an open database.
Definition: CBLBase.h:182
struct CBLListenerToken CBLListenerToken
An opaque 'cookie' representing a registered listener callback.
Definition: CBLBase.h:259
FLDict _cbl_nullable CBLQuery_Parameters(const CBLQuery *query)
Returns the query's current parameter bindings, if any.
_cbl_warn_unused FLArray CBLDatabase_GetIndexNames(CBLDatabase *db)
Returns the names of the indexes on this database, as a Fleece array of strings.
CBLQuery * CBLResultSet_GetQuery(const CBLResultSet *rs)
Returns the Query that created this ResultSet.
FLValue CBLResultSet_ValueForKey(const CBLResultSet *, FLString key)
Returns the value of a column of the current result, given its name.
void(* CBLQueryChangeListener)(void *_cbl_nullable context, CBLQuery *query, CBLListenerToken *token)
A callback to be invoked after the query's results have changed.
Definition: CBLQuery.h:204
void CBLQuery_SetParameters(CBLQuery *query, FLDict parameters)
Assigns values to the query's parameters.
_cbl_warn_unused FLSliceResult CBLQuery_Explain(const CBLQuery *)
Returns information about the query, including the translated SQLite form, and the search strategy.
FLSlice CBLQuery_ColumnName(const CBLQuery *, unsigned columnIndex)
Returns the name of a column in the result.
FLArray CBLResultSet_ResultArray(const CBLResultSet *)
Returns the current result as an array of column values.
CBLQueryLanguage
Query languages.
Definition: CBLQuery.h:43
FLDict CBLResultSet_ResultDict(const CBLResultSet *)
Returns the current result as a dictionary mapping column names to values.
_cbl_warn_unused CBLResultSet *_cbl_nullable CBLQuery_Execute(CBLQuery *, CBLError *_cbl_nullable outError)
Runs the query, returning the results.
_cbl_warn_unused bool CBLResultSet_Next(CBLResultSet *)
Moves the result-set iterator to the next result.
bool CBLDatabase_CreateFullTextIndex(CBLDatabase *db, FLString name, CBLFullTextIndexConfiguration config, CBLError *_cbl_nullable outError)
Creates a full-text index.
struct CBLQuery CBLQuery
A compiled database query.
Definition: CBLBase.h:203
struct CBLResultSet CBLResultSet
An iterator over the rows resulting from running a query.
Definition: CBLBase.h:206
_cbl_warn_unused CBLQuery *_cbl_nullable CBLDatabase_CreateQuery(const CBLDatabase *db, CBLQueryLanguage language, FLString queryString, int *_cbl_nullable outErrorPos, CBLError *_cbl_nullable outError)
Creates a new query by compiling the input string.
_cbl_warn_unused CBLListenerToken * CBLQuery_AddChangeListener(CBLQuery *query, CBLQueryChangeListener listener, void *_cbl_nullable context)
Registers a change listener callback with a query, turning it into a "live query" until the listener ...
_cbl_warn_unused CBLResultSet *_cbl_nullable CBLQuery_CopyCurrentResults(const CBLQuery *query, CBLListenerToken *listener, CBLError *_cbl_nullable outError)
Returns the query's entire current result set, after it's been announced via a call to the listener's...
bool CBLDatabase_DeleteIndex(CBLDatabase *db, FLString name, CBLError *_cbl_nullable outError)
Deletes an index given its name.
unsigned CBLQuery_ColumnCount(const CBLQuery *)
Returns the number of columns in each result.
bool CBLDatabase_CreateValueIndex(CBLDatabase *db, FLString name, CBLValueIndexConfiguration config, CBLError *_cbl_nullable outError)
Creates a value index.
FLValue CBLResultSet_ValueAtIndex(const CBLResultSet *, unsigned index)
Returns the value of a column of the current result, given its (zero-based) numeric index.
@ kCBLN1QLLanguage
N1QL syntax
Definition: CBLQuery.h:45
@ kCBLJSONLanguage
JSON query schema
Definition: CBLQuery.h:44
#define CBL_REFCOUNTED(TYPE, NAME)
Definition: CBLBase.h:170
const struct _FLDict * FLDict
A reference to a dictionary (map) value.
Definition: Fleece.h:51
const struct _FLArray * FLArray
A reference to an array value.
Definition: Fleece.h:50
const struct _FLValue * FLValue
A reference to a value of any type.
Definition: Fleece.h:49
A struct holding information about an error.
Definition: CBLBase.h:104
Full-Text Index Configuration.
Definition: CBLQuery.h:287
FLString expressions
The expressions describing each coloumn of the index.
Definition: CBLQuery.h:293
bool ignoreAccents
Should diacritical marks (accents) be ignored? Defaults to false.
Definition: CBLQuery.h:297
CBLQueryLanguage expressionLanguage
The language used in the expressions.
Definition: CBLQuery.h:289
FLString language
The dominant language.
Definition: CBLQuery.h:310
Value Index Configuration.
Definition: CBLQuery.h:267
FLString expressions
The expressions describing each coloumn of the index.
Definition: CBLQuery.h:273
CBLQueryLanguage expressionLanguage
The language used in the expressions.
Definition: CBLQuery.h:269
A simple reference to a block of memory.
Definition: FLSlice.h:46
A heap-allocated block of memory returned from an API call.
Definition: FLSlice.h:64