i new user in NOSQL and i find couchBase.
CBLView* view = [database viewNamed: @"note"];
if (!view.mapBlock) {
[view setMapBlock: MAPBLOCK({
if ([doc[@"doc_type"] isEqualToString: @"note"]) {
id date = [doc objectForKey: @"created_at"];
NSString* body = doc[@"text"];
emit(body,date);
}
}) reduceBlock: nil version: @"1"];
}
CBLQuery* query = [view createQuery];
NSError *err;
CBLQueryEnumerator *allDocument = [query run:&err];
this is work fine and and the allDocument have my array of note and it is ok
but i want to group my note with their name and count of each group
in sql this is something like this: SELECT count(*),name FROM note group by name
but in couch base i don't know how can i do that.
the note document is one CBMODEL like this:
#import <CouchbaseLite/CouchbaseLite.h>
@interface note : CBLModel
@property (readonly) NSString *doc_type;
@property (readonly) NSString *name;
@property (readonly) NSString *text;
@property (strong) NSDate *created_at;
-(instancetype)initInDatabase:(CBLDatabase *)database withType:(NSString *)type withname:(NSString *)name withtext:(NSString *)text;
@end