Couchbase Lite
Objective-C API for iOS and Mac OS
Instance Methods | Properties | List of all members
CBLQuery Class Reference

Represents a query of a CouchbaseLite 'view', or of a view-like resource like _all_documents. More...

#import <CBLQuery.h>

Inheritance diagram for CBLQuery:
CBLLiveQuery

Instance Methods

(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...
 

Properties

CBLDatabasedatabase
 The database that contains this view. 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...
 
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 -queryAllDocuments. 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...
 

Detailed Description

Represents a query of a CouchbaseLite 'view', or of a view-like resource like _all_documents.

Method Documentation

- (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: (CBLQueryEnumerator *) 
(NSError *)  onComplete 

Starts an asynchronous query.

Returns immediately, then calls the onComplete block when the query completes, passing it the row enumerator. If the query fails, the block will receive a non-nil enumerator but its .error property will be set to a value reflecting the error. The originating CBLQuery's .error property will NOT change.

- (CBLLiveQuery*) asLiveQuery

Returns a live query with the same parameters.

Property Documentation

- (CBLDatabase*) database
readatomicassign

The database that contains this view.

- (NSUInteger) limit
readwriteatomic

The maximum number of rows to return.

Default value is 0, meaning 'unlimited'.

- (NSUInteger) skip
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.

- (BOOL) descending
readwriteatomic

Should the rows be returned in descending key order? Default value is NO.

- (id) startKey
readwriteatomiccopy

If non-nil, the key value to start at.

- (id) endKey
readwriteatomiccopy

If non-nil, the key value to end after.

- (NSString*) startKeyDocID
readwriteatomiccopy

If non-nil, the document ID to start at.

(Useful if the view contains multiple identical keys, making .startKey ambiguous.)

- (NSString*) endKeyDocID
readwriteatomiccopy

If non-nil, the document ID to end at.

(Useful if the view contains multiple identical keys, making .endKey ambiguous.)

- (CBLIndexUpdateMode) indexUpdateMode
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.

- (NSArray*) keys
readwriteatomiccopy

If non-nil, the query will fetch only the rows with the given keys.

- (BOOL) mapOnly
readwriteatomic

If set to YES, disables use of the reduce function.

(Equivalent to setting "?reduce=false" in the REST API.)

- (NSUInteger) groupLevel
readwriteatomic

If non-zero, enables grouping of results, in views that have reduce functions.

- (BOOL) prefetch
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.

- (CBLAllDocsMode) allDocsMode
readwriteatomic

Changes the behavior of a query created by -queryAllDocuments.

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.)

- (NSString*) fullTextQuery
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 string syntax is described in http://sqlite.org/fts3.html#section_3 . The query rows produced by this search will be instances of CBLFullTextQueryRow. 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).

- (BOOL) fullTextSnippets
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).

- (BOOL) fullTextRanking
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).

- (CBLGeoRect) boundingBox
readwriteatomic

The geometric bounding box to search.

Setting this property causes the query to search geometries rather than keys.

Provided by category CBLQuery(Geo).


The documentation for this class was generated from the following file: