CBLQuery
@interface CBLQuery : NSObject
A database query. A CBLQuery instance can be constructed by calling one of the select class methods.
-
Create a query from SELECT and FROM component.
Declaration
Objective-C
+ (nonnull instancetype)select:(nonnull CBLQuerySelect *)select from:(nonnull CBLQueryDataSource *)from;
Swift
class func select(_ select: CBLQuerySelect, from: CBLQueryDataSource) -> Self
-
Create a DISTINCT query from SELECT and FROM component.
Declaration
Objective-C
+ (nonnull instancetype)selectDistict:(nonnull CBLQuerySelect *)selectDistict from:(nonnull CBLQueryDataSource *)from;
Swift
class func selectDistict(_ selectDistict: CBLQuerySelect, from: CBLQueryDataSource) -> Self
-
Create a query from SELECT, FROM, and WHERE component.
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?) -> Self
-
Create a DISTINCT query from SELECT, FROM, and WHERE component.
Declaration
Objective-C
+ (nonnull instancetype)selectDistict:(nonnull CBLQuerySelect *)selectDistict from:(nonnull CBLQueryDataSource *)from where:(nullable CBLQueryExpression *)where;
Swift
class func selectDistict(_ selectDistict: CBLQuerySelect, from: CBLQueryDataSource, where: CBLQueryExpression?) -> Self
-
Create a query from SELECT, FROM, WHERE, and ORDERBY component.
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?) -> Self
-
Create a DISTINCT query from SELECT, FROM, WHERE, and ORDERBY component.
Declaration
Objective-C
+ (nonnull instancetype)selectDistict:(nonnull CBLQuerySelect *)selectDistict from:(nonnull CBLQueryDataSource *)from where:(nullable CBLQueryExpression *)where orderBy:(nullable CBLQueryOrderBy *)orderBy;
Swift
class func selectDistict(_ selectDistict: CBLQuerySelect, from: CBLQueryDataSource, where: CBLQueryExpression?, orderBy: CBLQueryOrderBy?) -> Self
-
Checks whether the query is valid, recompiling it if necessary, without running it.
Declaration
Objective-C
- (BOOL)check:(NSError *_Nullable *_Nullable)outError;
Swift
func check() throws
-
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 seeSCAN TABLE
, it means that SQLite is doing a slow linear scan of the documents instead of using an index.Declaration
Objective-C
- (nullable NSString *)explain:(NSError *_Nullable *_Nullable)outError;
Swift
func explain() throws -> String
-
Runs the query, using the current settings (skip, limit, parameters), 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.
Declaration
Objective-C
- (nullable NSEnumerator<CBLQueryRow *> *)run: (NSError *_Nullable *_Nullable)outError;
Swift
func run() throws -> NSEnumerator
-
Undocumented
Declaration
Objective-C
@interface CBLQuery : NSObject