Hi, i'm working to insert couchbase in my iOS app and i am a bit stuck to this stage:
I have to get all document of a given kind and extract only the ones have a flag set true, so basically a normal query.
My actual method to do this is that:
- (NSArray *) getCompletedWorkouts{
NSError *error;
//1- createView
CBLView * contactInfoView = [_cl_database viewNamed: @"getCompletedWorkouts"];
[contactInfoView setMapBlock: MAPBLOCK({
if (doc[@"workout"])
emit(doc[@"workout"], nil);
}) version: @"1"];
//2 - make the query
CBLQuery* query = [contactInfoView createQuery];
CBLQueryEnumerator* result = [query run: &error];
for(CBLQueryRow* row in result)
{
NSLog(@"Found document: %@", row.document);
}
if (error) {
NSLog(@"Document NOT found, error = %@", error.localizedDescription);
}
return [NSArray array];
}
with this method i get in console all document, so how can i select only documents of a kind and with said flag true? In particularly i didn't found a lot of documentation on map block, is there the place where i have to place the conditions?
Sorry for my newbieness in this field, but i found couchbase a bit hard to understand at the start, more then other DB implementations. THX