hi dear Jens Alfke
i new user in NOSQL and i find couchBase.
in one of my project i want to show my notes document with type = "note"
i can do that with this code :
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
i want to give answer with NSLog like this
name of note :cat count of note:12
name of note:dog count of note:28
please help me
i confuse
thanks a lot
--
You received this message because you are subscribed to the Google Groups
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/mobile-couchbase/bf3a1af7-bdcb-458a-80d8-4bb79fe79818%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.