CBLQuery
@interface CBLQuery : NSObject
A database query. A CBLQuery instance can be constructed by calling one of the select methods.
-
Create a query from the select and from component. - parameter: select the select component reresenting the SELECT clause of the query. - parameter: from the from component representing the FROM clause of the query. - returns: the CBLQuery instance.
Declaration
Objective-C
+ (nonnull instancetype)select:(nonnull CBLQuerySelect *)select from:(nonnull CBLQueryDataSource *)from;
Parameters
select
from
-
Create a distinct query from the select and from component. - parameter: selectDistinct the select component representing the SELECT clause of the query. - parameter: from the from component representing the FROM clause of the query. - returns: the CBLQuery instance.
Declaration
Objective-C
+ (nonnull instancetype)selectDistinct:(nonnull CBLQuerySelect *)selectDistinct from:(nonnull CBLQueryDataSource *)from;
Parameters
selectDistinct
from
-
Create a query from the select, from, and where component. - parameter: select the select component representing the SELECT clause of the query. - parameter: from the from component representing the FROM clause of the query. - parameter: where the where component representing the WHERE clause of the query. - returns: the CBLQuery instance.
Declaration
Objective-C
+ (nonnull instancetype)select:(nonnull CBLQuerySelect *)select from:(nonnull CBLQueryDataSource *)from where:(nullable CBLQueryExpression *)where;
Parameters
select
from
where
-
Create a distinct query from the select, from, and where component. - parameter: selectDistinct the select component representing the SELECT clause of the query. - parameter: from the from component representing the FROM clause of the query. - parameter: where the where component representing the WHERE clause of the query. - returns: the CBLQuery instance.
Declaration
Objective-C
+ (nonnull instancetype)selectDistinct:(nonnull CBLQuerySelect *)selectDistinct from:(nonnull CBLQueryDataSource *)from where:(nullable CBLQueryExpression *)where;
Parameters
selectDistinct
from
where
-
Create a query Create a query from the select, from, where, and order by component. - parameter: select the select component representing the SELECT clause of the query. - parameter: from the from component representing the FROM clause of the query. - parameter: where the where component representing the WHERE clause of the query. - parameter: orderBy the order by component representing the ORDER BY clause of the query. - returns: the CBLQuery instance.
Declaration
Objective-C
+ (nonnull instancetype)select:(nonnull CBLQuerySelect *)select from:(nonnull CBLQueryDataSource *)from where:(nullable CBLQueryExpression *)where orderBy:(nullable CBLQueryOrderBy *)orderBy;
Parameters
select
from
where
orderBy
-
Create a distinct query Create a query from the select, from, where, and order by component. - parameter: selectDistinct the select component representing the SELECT clause of the query. - parameter: from the from component representing the FROM clause of the query. - parameter: where the where component representing the WHERE clause of the query. - parameter: orderBy the order by component representing the ORDER BY clause of the query. - returns: the CBLQuery instance.
Declaration
Objective-C
+ (nonnull instancetype)selectDistinct:(nonnull CBLQuerySelect *)selectDistinct from:(nonnull CBLQueryDataSource *)from where:(nullable CBLQueryExpression *)where orderBy:(nullable CBLQueryOrderBy *)orderBy;
Parameters
selectDistinct
from
where
orderBy
-
Checks whether the query is valid, recompiling it if necessary, without running it. - parameter: outError If an error occurs, it will be stored here if this parameter is non-NULL. - returns: YES if the query is valid, or NO if the query is not valid.
Declaration
Objective-C
- (BOOL)check:(NSError *_Nullable *_Nullable)outError;
Parameters
outError
-
Returns a string describing the implementation of the compiled query. This is intended to be read by a developer for purposes of optimizing the query, especially to add database indexes. It’s not machine-readable and its format may change.
As currently implemented, the result is two or more lines separated by newline characters: * The first line is the SQLite SELECT statement. * The subsequent lines are the output of SQLite's "EXPLAIN QUERY PLAN" command applied to that statement; for help interpreting this, see https://www.sqlite.org/eqp.html . The most important thing to know is that if you see "SCAN TABLE", it means that SQLite is doing a slow linear scan of the documents instead of using an index. - parameter: outError If an error occurs, it will be stored here if this parameter is non-NULL. - returns: a string describing the implementation of the compiled query.
Declaration
Objective-C
- (nullable NSString *)explain:(NSError *_Nullable *_Nullable)outError;
Parameters
outError
-
Runs the query. The returning an enumerator that returns result rows one at a time. You can run the query any number of times, and you can even have multiple enumerators active at once. The results come from a snapshot of the database taken at the moment -run: is called, so they will not reflect any changes made to the database afterwards. - parameter: outError If an error occurs, it will be stored here if this parameter is non-NULL. - returns: an enumerator of the query result.
Declaration
Objective-C
- (nullable NSEnumerator<CBLQueryRow *> *)run: (NSError *_Nullable *_Nullable)outError;
Parameters
outError
-
Returns a live query based on the current query. - returns: a live query object.
Declaration
Objective-C
- (nonnull CBLLiveQuery *)toLive;
-
Undocumented
Declaration
Objective-C
@interface CBLQuery : NSObject