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;Swift
class func select(_ select: CBLQuerySelect, from: CBLQueryDataSource) -> SelfParameters
selectthe select component reresenting the SELECT clause of the query.
fromthe from component representing the FROM clause of the query.
Return Value
the CBLQuery instance.
-
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;Swift
class func selectDistinct(_ selectDistinct: CBLQuerySelect, from: CBLQueryDataSource) -> SelfParameters
selectDistinctthe select component representing the SELECT clause of the query.
fromthe from component representing the FROM clause of the query.
Return Value
the CBLQuery instance.
-
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;Swift
class func select(_ select: CBLQuerySelect, from: CBLQueryDataSource, where: CBLQueryExpression?) -> SelfParameters
selectthe select component representing the SELECT clause of the query.
fromthe from component representing the FROM clause of the query.
wherethe where component representing the WHERE clause of the query.
Return Value
the CBLQuery instance.
-
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;Swift
class func selectDistinct(_ selectDistinct: CBLQuerySelect, from: CBLQueryDataSource, where: CBLQueryExpression?) -> SelfParameters
selectDistinctthe select component representing the SELECT clause of the query.
fromthe from component representing the FROM clause of the query.
wherethe where component representing the WHERE clause of the query.
Return Value
the CBLQuery instance.
-
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;Swift
class func select(_ select: CBLQuerySelect, from: CBLQueryDataSource, where: CBLQueryExpression?, orderBy: CBLQueryOrderBy?) -> SelfParameters
selectthe select component representing the SELECT clause of the query.
fromthe from component representing the FROM clause of the query.
wherethe where component representing the WHERE clause of the query.
orderBythe order by component representing the ORDER BY clause of the query.
Return Value
the CBLQuery instance.
-
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;Swift
class func selectDistinct(_ selectDistinct: CBLQuerySelect, from: CBLQueryDataSource, where: CBLQueryExpression?, orderBy: CBLQueryOrderBy?) -> SelfParameters
selectDistinctthe select component representing the SELECT clause of the query.
fromthe from component representing the FROM clause of the query.
wherethe where component representing the WHERE clause of the query.
orderBythe order by component representing the ORDER BY clause of the query.
Return Value
the CBLQuery instance.
-
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;Swift
func check() throwsParameters
outErrorIf an error occurs, it will be stored here if this parameter is non-NULL.
Return Value
YES if the query is valid, or NO if the query is not valid.
-
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;Swift
func explain() throws -> StringParameters
outErrorIf an error occurs, it will be stored here if this parameter is non-NULL.
Return Value
a string describing the implementation of the compiled query.
-
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;Swift
func run() throws -> NSEnumeratorParameters
outErrorIf an error occurs, it will be stored here if this parameter is non-NULL.
Return Value
an enumerator of the query result.
-
Undocumented
Declaration
Objective-C
@interface CBLQuery : NSObject
CBLQuery Class Reference