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
23
24
42typedef CBL_ENUM(uint32_t, CBLQueryLanguage) {
45};
46
47
68 CBLQueryLanguage language,
69 FLString queryString,
70 int* _cbl_nullable outErrorPos,
71 CBLError* _cbl_nullable outError) CBLAPI;
72
74
87 FLDict parameters) CBLAPI;
88
91
98 CBLError* _cbl_nullable outError) CBLAPI;
99
107
110
118 unsigned columnIndex) CBLAPI;
119
149
154 unsigned index) CBLAPI;
155
162 FLString key) CBLAPI;
163
168
173
176
178
202typedef void (*CBLQueryChangeListener)(void* _cbl_nullable context,
203 CBLQuery* query,
204 CBLListenerToken* token);
205
219 CBLQueryChangeListener listener,
220 void* _cbl_nullable context) CBLAPI;
221
231 CBLListenerToken *listener,
232 CBLError* _cbl_nullable outError) CBLAPI;
233
265typedef struct {
268
273
280 FLString name,
282 CBLError* _cbl_nullable outError) CBLAPI;
283
284
286typedef struct {
289
293
298
312
319 FLString name,
321 CBLError* _cbl_nullable outError) CBLAPI;
322
326 FLString name,
327 CBLError* _cbl_nullable outError) CBLAPI;
328
334
#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_ENUM(_type, _name)
Definition: CBL_Compat.h:62
#define _cbl_warn_unused
Definition: CBL_Compat.h:40
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:271
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:202
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:42
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:215
struct CBLResultSet CBLResultSet
An iterator over the rows resulting from running a query.
Definition: CBLBase.h:218
_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:44
@ kCBLJSONLanguage
JSON query schema
Definition: CBLQuery.h:43
#define CBL_REFCOUNTED(TYPE, NAME)
Definition: CBLBase.h:170
const struct _FLDict * FLDict
A reference to a dictionary (map) value.
Definition: FLBase.h:37
const struct _FLArray * FLArray
A reference to an array value.
Definition: FLBase.h:36
const struct _FLValue * FLValue
A reference to a value of any type.
Definition: FLBase.h:35
A struct holding information about an error.
Definition: CBLBase.h:104
Full-Text Index Configuration.
Definition: CBLQuery.h:286
FLString expressions
The expressions describing each coloumn of the index.
Definition: CBLQuery.h:292
bool ignoreAccents
Should diacritical marks (accents) be ignored? Defaults to kCBLDefaultFullTextIndexIgnoreAccents.
Definition: CBLQuery.h:297
CBLQueryLanguage expressionLanguage
The language used in the expressions (Required).
Definition: CBLQuery.h:288
FLString language
The dominant language.
Definition: CBLQuery.h:310
Value Index Configuration.
Definition: CBLQuery.h:265
FLString expressions
The expressions describing each coloumn of the index.
Definition: CBLQuery.h:271
CBLQueryLanguage expressionLanguage
The language used in the expressions.
Definition: CBLQuery.h:267
A simple reference to a block of memory.
Definition: FLSlice.h:45
A heap-allocated block of memory returned from an API call.
Definition: FLSlice.h:63