View
A Couchbase Lite View. A View defines a persistent index managed by map/reduce.
Syntax
@interface CBLView : NSObject
class CBLView : NSObject
public class View
public class View
public class View
Summary
| Properties | |
|---|---|
compiler { get; set; } Gets or sets an object that can compile source code into map and reduce delegates. | |
database { get; } | |
isStale { get; } Gets if the View's indes is currently out of date. | |
lastSequenceIndexed { get; } Gets the last sequence number indexed so far. | |
map { get; } Gets the View's MapDelegate. | |
name { get; } Gets the View's name. | |
reduce { get; } Gets the View's ReduceDelegate. | |
| Methods | |
|---|---|
Creates a new Query for this view. | |
delete() Deletes the View. | |
setMap(MapDelegate map, String version) | |
| Delegates | |
|---|---|
EmitDelegate(Object key, Object value) A delegate that can be invoked to add key/values to a View during a MapDelegate call. | |
MapDelegate(Map<String, Object> document, EmitDelegate emit) | |
ReduceDelegate(Object[] keys, Object[] values, boolean rereduce) A delegate that can be invoked to summarize the results of a View. | |
Properties
static ViewCompiler compiler { get; set; }
Gets or sets an object that can compile source code into map and reduce delegates.
Syntax
+(id<CBLViewCompiler>)compiler
+(void)setCompiler:(id<CBLViewCompiler>)compiler
class func compiler() -> CBLViewCompiler!
class func setCompiler(compiler: CBLViewCompiler!)
public static ViewCompiler getCompiler()
public static void setCompiler(ViewCompiler compiler)
public static ViewCompiler getCompiler()
public static void setCompiler(ViewCompiler compiler)
public static IViewCompiler Compiler { get; set; }
Database database { get; }
Syntax
@property (readonly) CBLDatabase * database
var database: CBLDatabase! { get }
public Database getDatabase()
public Database getDatabase()
public Database Database { get; }
boolean isStale { get; }
Gets if the View's indes is currently out of date.
Syntax
@property (readonly) BOOL stale
var stale: Bool { get }
public boolean isStale()
public boolean isStale()
public Boolean IsStale { get; }
long lastSequenceIndexed { get; }
Gets the last sequence number indexed so far.
Syntax
@property (readonly) SInt64 lastSequenceIndexed
var lastSequenceIndexed: Int64 { get }
public long getLastSequenceIndexed()
public long getLastSequenceIndexed()
public long LastSequenceIndexed { get; }
MapDelegate map { get; }
Gets the View's MapDelegate.
Syntax
@property (readonly) CBLMapBlock * mapBlock
var mapBlock: CBLMapBlock! { get }
public Mapper getMap()
public Mapper getMap()
public MapDelegate Map { get; }
String name { get; }
Gets the View's name.
Syntax
@property (readonly) NSString * name
name: String! { get }
public String getName()
public String getName()
public String Name { get; }
ReduceDelegate reduce { get; }
Gets the View's ReduceDelegate.
Syntax
@property (readonly) CBLReduceBlock * reduceBlock
var reduceBlock: CBLReduceBlock! { get }
public ReduceDelegate getReduce()
public ReduceDelegate getReduce()
public ReduceDelegate Reduce { get; }
Methods
Query createQuery()
Creates a new Query for this view.
Returns
A new Query for this view.
Syntax
-(CBLQuery *)createQuery
func createQuery() -> CBLQuery!
public Query createQuery()
public Query createQuery()
public Query CreateQuery()
void delete()
Deletes the View.
Syntax
-(void)deleteView
func deleteView()
public void delete()
public void delete()
public void Delete()
void deleteIndex()
Syntax
-(void)deleteIndex
func deleteIndex()
public void deleteIndex()
public void deleteIndex()
public void DeleteIndex()
boolean setMap(MapDelegate map, String version)
Parameters
| map | The MapDelegate to set. |
| version | The key of the property value to return. The value of this parameter must change when the MapDelegate is changed in a way that will cause it to produce different results. |
Returns
True if the MapDelegate was set, otherwise false. If the values provided are identical to the values that are already set, then the values will not be updated and false will be returned. In addition, if true is returned, the index was deleted and will be rebuilt on the next Query execution.
Syntax
-(BOOL)setMapBlock:(CBLMapBlock)mapBlock version:(NSString *)version
func setMapBlock(mapBlock: CBLMapBlock!, version: String!) -> Bool
public boolean setMap(Mapper map, String version)
public boolean setMap(Mapper map, String version)
public Boolean SetMap(MapDelegate map, String version)
boolean setMapReduce(MapDelegate map, ReduceDelegate reduce, String version)
Parameters
| map | The MapDelegate to set. |
| reduce | The ReduceDelegate to set. |
| version | The key of the property value to return. The value of this parameter must change when the MapDelegate and/or ReduceDelegate are changed in a way that will cause them to produce different results. |
Returns
True if the MapDelegate and ReduceDelegate were set, otherwise false. If the values provided are identical to the values that are already set, then the values will not be updated and false will be returned. In addition, if true is returned, the index was deleted and will be rebuilt on the next Query execution.
Syntax
-(BOOL)setMapBlock:(CBLMapBlock)mapBlock reduceBlock:(CBLReduceBlock)reduceBlock version:(NSString *)version
func setMapBlock(mapBlock: CBLMapBlock!, reduceBlock: CBLReduceBlock!, version: String!) -> Bool
public boolean setMapReduce(Mapper map, Reducer reduce, String version)
public boolean setMapReduce(Mapper map, Reducer reduce, String version)
public Boolean SetMapReduce(MapDelegate map, ReduceDelegate reduce, String version)
Delegates
void EmitDelegate(Object key, Object value)
A delegate that can be invoked to add key/values to a View during a MapDelegate call.
Parameters
| key | The key. |
| value | The value. |
Syntax
typedef void (^CBLMapEmitBlock)(id key, id value)
typealias CBLMapEmitBlock = (AnyObject!, AnyObject!) -> Void
public interface Emitter {
void emit(Object key, Object value);
}
public interface Emitter {
void emit(Object key, Object value);
}
public delegate void EmitDelegate(Object key, Object value);
void MapDelegate(Map<String, Object> document, EmitDelegate emit)
Parameters
| document | The Document being mapped. |
| emit | The delegate to use to add key/values to the View. |
Syntax
typedef void (^CBLMapBlock)(NSDictionary * doc, CBLMapEmitBlock emit)
typealias CBLMapBlock = ([NSObject : AnyObject]!, CBLMapEmitBlock!) -> Void
public interface Mapper {
void map(Map<String, Object> document, Emitter emitter);
}
public interface Mapper {
void map(Map<String, Object> document, Emitter emitter);
}
public delegate void MapDelegate(Dictionary<String, Object> document, EmitDelegate emit);
Object ReduceDelegate(Object[] keys, Object[] values, boolean rereduce)
A delegate that can be invoked to summarize the results of a View.
Parameters
| keys | A list of keys to be reduced, or null if this is a rereduce. |
| values | A parallel array of values to be reduced, corresponding 1-to-1 with the keys. |
| rereduce | True if the input values are the results of previous reductions, otherwise false. |
Returns
The reduced value.
Syntax
typedef id (^CBLReduceBlock)(NSArray * keys, NSArray * values, BOOL rereduce)
typealias CBLReduceBlock = ([AnyObject]!, [AnyObject]!, Bool) -> AnyObject!
public interface Reducer {
Object reduce(List<Object> keys, List<Object> values, boolean rereduce);
}
public interface Reducer {
Object reduce(List<Object> keys, List<Object> values, boolean rereduce);
}
public delegate Object ReduceDelegate(IEnumerable<Object> keys, IEnumerable<Object> values, Boolean rereduce);