![]() |
Couchbase Lite
Objective-C API for iOS and Mac OS
|
Represents a query of a CouchbaseLite 'view', or of a view-like resource like _all_documents.
Instance Methods | |
| () | - CBLArrayOf |
| An optional array of NSSortDescriptor objects; overrides the default by-key ordering. More... | |
| (nullable CBLQueryEnumerator *) | - run: |
| Sends the query to the server and returns an enumerator over the result rows (Synchronous). More... | |
| (void) | - runAsync: |
| Starts an asynchronous query. More... | |
| (CBLLiveQuery *) | - asLiveQuery |
| Returns a live query with the same parameters. More... | |
| (instancetype) | - NS_UNAVAILABLE |
Properties | |
| CBLView * | view |
| The view being queried; nil if this is an all-documents query. More... | |
| CBLDatabase * | database |
| The database being queried. More... | |
| NSUInteger | limit |
| The maximum number of rows to return. More... | |
| NSUInteger | skip |
| The number of initial rows to skip. More... | |
| BOOL | descending |
| Should the rows be returned in descending key order? Default value is NO. More... | |
| id | startKey |
| If non-nil, the key value to start at. More... | |
| id | endKey |
| If non-nil, the key value to end after. More... | |
| NSString * | startKeyDocID |
| If non-nil, the document ID to start at. More... | |
| NSString * | endKeyDocID |
| If non-nil, the document ID to end at. More... | |
| BOOL | inclusiveStart |
| If YES (the default) the startKey (or startKeyDocID) comparison uses ">=". More... | |
| BOOL | inclusiveEnd |
| If YES (the default) the endKey (or endKeyDocID) comparison uses "<=". More... | |
| NSUInteger | prefixMatchLevel |
| If nonzero, enables prefix matching of string or array keys. More... | |
| NSPredicate * | postFilter |
| An optional predicate that filters the resulting query rows. More... | |
| CBLIndexUpdateMode | indexUpdateMode |
| Determines whether or when the view index is updated. More... | |
| NSArray * | keys |
| If non-nil, the query will fetch only the rows with the given keys. More... | |
| BOOL | mapOnly |
| If set to YES, disables use of the reduce function. More... | |
| NSUInteger | groupLevel |
| If non-zero, enables grouping of results, in views that have reduce functions. More... | |
| BOOL | prefetch |
| If set to YES, the results will include the entire document contents of the associated rows. More... | |
| CBLAllDocsMode | allDocsMode |
| Changes the behavior of a query created by -createAllDocumentsQuery. More... | |
| NSString * | fullTextQuery |
| Query string for a full-text search; works only if the view's map function has triggered full- text indexing by emitting strings wrapped by CBLTextKey(). More... | |
| BOOL | fullTextSnippets |
| If set to YES, the query will collect snippets of the text surrounding each match, available via the CBLFullTextQueryRow's -snippetWithWordStart:wordEnd: method. More... | |
| BOOL | fullTextRanking |
| If YES (the default) the full-text query result rows will be sorted by (approximate) relevance. More... | |
| CBLGeoRect | boundingBox |
| The geometric bounding box to search. More... | |
| - CBLArrayOf | (NSSortDescriptor *) |
An optional array of NSSortDescriptor objects; overrides the default by-key ordering.
Key-paths are interpreted relative to a CBLQueryRow object, so they should start with "value" to refer to the value, or "key" to refer to the key. A limited form of array indexing is supported, so you can refer to "key[1]" or "value[0]" if the key or value are arrays. This only works with indexes from 0 to 3.
| - (nullable CBLQueryEnumerator*) run: | (NSError **) | outError |
Sends the query to the server and returns an enumerator over the result rows (Synchronous).
Note: In a CBLLiveQuery you should access the .rows property instead.
| - (void) runAsync: | (void(^)(CBLQueryEnumerator *, NSError *)) | onComplete |
Starts an asynchronous query.
Returns immediately, then calls the onComplete block when the query completes, passing it the row enumerator (or an error).
| - (CBLLiveQuery*) asLiveQuery |
Returns a live query with the same parameters.
| - (instancetype) NS_UNAVAILABLE |
|
readatomicassign |
The view being queried; nil if this is an all-documents query.
|
readatomicassign |
The database being queried.
|
readwriteatomic |
The maximum number of rows to return.
Defaults to 'unlimited' (UINT_MAX).
|
readwriteatomic |
The number of initial rows to skip.
Default value is 0. Should only be used with small values. For efficient paging, use startKey and limit.
|
readwriteatomic |
Should the rows be returned in descending key order? Default value is NO.
|
readwriteatomiccopy |
If non-nil, the key value to start at.
|
readwriteatomiccopy |
If non-nil, the key value to end after.
|
readwriteatomiccopy |
If non-nil, the document ID to start at.
(Useful if the view contains multiple identical keys, making .startKey ambiguous.)
|
readwriteatomiccopy |
If non-nil, the document ID to end at.
(Useful if the view contains multiple identical keys, making .endKey ambiguous.)
|
readwriteatomic |
If YES (the default) the startKey (or startKeyDocID) comparison uses ">=".
Else it uses ">".
|
readwriteatomic |
If YES (the default) the endKey (or endKeyDocID) comparison uses "<=".
Else it uses "<".
|
readwriteatomic |
If nonzero, enables prefix matching of string or array keys.
A value of 1 treats the endKey itself as a prefix: if it's a string, keys in the index that come after the endKey, but begin with the same prefix, will be matched. (For example, if the endKey is "foo" then the key "foolish" in the index will be matched, but not "fong".) Or if the endKey is an array, any array beginning with those elements will be matched. (For example, if the endKey is [1], then [1, "x"] will match, but not [2].) If the key is any other type, there is no effect. A value of 2 assumes the endKey is an array and treats its final item as a prefix, using the rules above. (For example, an endKey of [1, "x"] will match [1, "xtc"] but not [1, "y"].) A value of 3 assumes the key is an array of arrays, etc. Note that if the .descending property is also set, the search order is reversed and the above discussion applies to the startKey, not the endKey.
|
readwriteatomicstrong |
An optional predicate that filters the resulting query rows.
If present, it's called on every row returned from the query, and if it returns NO the row is skipped. Key-paths are interpreted relative to a CBLQueryRow, so they should start with "value" to refer to the value, or "key" to refer to the key.
|
readwriteatomic |
Determines whether or when the view index is updated.
By default, the index will be updated if necessary before the query runs – this guarantees up-to-date results but can cause a delay. The "Never" mode skips updating the index, so it's faster but can return out of date results. The "After" mode is a compromise that may return out of date results but if so will start asynchronously updating the index after the query so future results are accurate.
|
readwriteatomiccopy |
If non-nil, the query will fetch only the rows with the given keys.
|
readwriteatomic |
If set to YES, disables use of the reduce function.
(Equivalent to setting "?reduce=false" in the REST API.)
|
readwriteatomic |
If non-zero, enables grouping of results, in views that have reduce functions.
|
readwriteatomic |
If set to YES, the results will include the entire document contents of the associated rows.
These can be accessed via CBLQueryRow's -documentProperties property. This slows down the query, but can be a good optimization if you know you'll need the entire contents of each document.
|
readwriteatomic |
Changes the behavior of a query created by -createAllDocumentsQuery.
In mode kCBLAllDocs (the default), the query simply returns all non-deleted documents. In mode kCBLIncludeDeleted, it also returns deleted documents. In mode kCBLShowConflicts, the .conflictingRevisions property of each row will return the conflicting revisions, if any, of that document. In mode kCBLOnlyConflicts, only documents in conflict will be returned. (This mode is especially useful for use with a CBLLiveQuery, so you can be notified of conflicts as they happen, i.e. when they're pulled in by a replication.)
|
readwriteatomiccopy |
Query string for a full-text search; works only if the view's map function has triggered full- text indexing by emitting strings wrapped by CBLTextKey().
The query rows produced by this search will be instances of CBLFullTextQueryRow.
The query string will be broken up into words. "Noise" words like "the" and "hello" (also called "stop-words") are ignored.
The result will include a row corresponding to every emitted CBLTextKey() that contains any of the words in the query. Word matching tries to account for (English) grammatical variations like plurals and verb tenses, so for example "cat" will match "cats" and "type" will match "typing".
NOTE:** Full-text views have no keys, so the key-related query properties will be ignored. They also can't be reduced or grouped, so those properties are ignored too.
Provided by category CBLQuery(FullTextSearch).
|
readwriteatomic |
If set to YES, the query will collect snippets of the text surrounding each match, available via the CBLFullTextQueryRow's -snippetWithWordStart:wordEnd: method.
Provided by category CBLQuery(FullTextSearch).
|
readwriteatomic |
If YES (the default) the full-text query result rows will be sorted by (approximate) relevance.
If set to NO, the rows will be returned in the order the documents were added to the database, i.e. essentially unordered; this is somewhat faster, so it can be useful if you don't care about the ordering of the rows.
Provided by category CBLQuery(FullTextSearch).
|
readwriteatomic |
The geometric bounding box to search.
Setting this property causes the query to search geometries rather than keys.
Provided by category CBLQuery(Geo).