Couchbase Lite
Objective-C API for iOS and Mac OS
CBLView.h File Reference
#import <Foundation/Foundation.h>

Go to the source code of this file.

Classes

protocol  <CBLViewCompiler >
 An external object that knows how to map source code of some sort into executable functions. More...
 
class  CBLView
 A "view" in a CouchbaseLite database – essentially a persistent index managed by map/reduce. More...
 

Macros

#define MAPBLOCK(BLOCK)   ^(CBLJSONDict* doc, void (^emit)(id key, id value)){BLOCK}
 
#define REDUCEBLOCK(BLOCK)   ^id(NSArray* keys, NSArray* values, BOOL rereduce){BLOCK}
 

Typedefs

typedef void(^ CBLMapEmitBlock) (id key, __nullable id value)
 
typedef void(^ CBLMapBlock) (CBLJSONDict *doc, CBLMapEmitBlock emit)
 A "map" function called when a document is to be added to a view. More...
 
typedef __nonnull id(^ CBLReduceBlock) (NSArray *__nonnull keys, NSArray *__nonnull values, BOOL rereduce)
 A "reduce" function called to summarize the results of a view. More...
 

Enumerations

enum  CBLViewIndexType { kCBLMapReduceIndex = 1, kCBLFullTextIndex, kCBLGeoIndex }
 

Functions

FOUNDATION_EXTERN id CBLTextKey (NSString *text)
 Returns a special value that, when emitted as a key, causes the given text to be indexed with the full-text indexer. More...
 

Macro Definition Documentation

◆ MAPBLOCK

#define MAPBLOCK (   BLOCK)    ^(CBLJSONDict* doc, void (^emit)(id key, id value)){BLOCK}

◆ REDUCEBLOCK

#define REDUCEBLOCK (   BLOCK)    ^id(NSArray* keys, NSArray* values, BOOL rereduce){BLOCK}

Typedef Documentation

◆ CBLMapEmitBlock

typedef void(^ CBLMapEmitBlock) (id key, __nullable id value)

◆ CBLMapBlock

typedef void(^ CBLMapBlock) (CBLJSONDict *doc, CBLMapEmitBlock emit)

A "map" function called when a document is to be added to a view.

Parameters
docThe contents of the document being analyzed.
emitA block to be called to add a key/value pair to the view. Your block can call it zero, one or multiple times.

◆ CBLReduceBlock

typedef __nonnull id(^ CBLReduceBlock) (NSArray *__nonnull keys, NSArray *__nonnull values, BOOL rereduce)

A "reduce" function called to summarize the results of a view.

Parameters
keysAn array of keys to be reduced (or nil if this is a rereduce).
valuesA parallel array of values to be reduced, corresponding 1::1 with the keys.
rereduceYES if the input values are the results of previous reductions.
Returns
The reduced value; almost always a scalar or small fixed-size object.

Enumeration Type Documentation

◆ CBLViewIndexType

Enumerator
kCBLMapReduceIndex 

Regular map/reduce index with JSON keys.

kCBLFullTextIndex 

Keys must be strings and will be indexed by the words they contain.

kCBLGeoIndex 

Geo-query index; not supported yet.

Function Documentation

◆ CBLTextKey()

FOUNDATION_EXTERN id CBLTextKey ( NSString *  text)

Returns a special value that, when emitted as a key, causes the given text to be indexed with the full-text indexer.

Used inside a map block, like so: emit(CBLTextKey(longText), value);