//********** customer View search:
CBLView* view = [self.database viewNamed: @"client/docView"];
[view setMapBlock: ^(NSDictionary* doc, void (^emit)(id key, id value)) {
NSString* type = [doc objectForKey: @"type"];
NSArray * value = [NSArray arrayWithObjects:
[doc objectForKey: @"id"],
[doc objectForKey: @"description1"],
nil];
if ([type isEqualToString:@"CLIE"]) emit([doc objectForKey:@"_id"], value);
} version: @"1.0"];
//*********** product varianty
view = [self.database viewNamed: @"prodVersion/docView"];
[view setMapBlock: ^(NSDictionary* doc, void (^emit)(id key, id value)) {
NSString* type = [doc objectForKey: @"type"];
NSArray * value1 = [NSArray arrayWithObjects:
[doc objectForKey: @"code"],
[doc objectForKey: @"id"],
[doc objectForKey: @"versionCode"],
nil];
if ([type isEqualToString:@"product"]) emit([doc objectForKey:@"_id"], value1);
} version: @"1.0"];
How can i check the existence of my views when the app is launched , if it's not the will be created ,
because when i insert new doc and i do get to the view, the result is not updating, i have to reopen the app to have the view updated !!
i m querying the view from service with angularjs like this :GETProductsForSearch: function(callback) {
return $http({method: "GET", url: database+"/_design/prodVersion/_view/docView", cache: $templateCache}).success(callback).error(function(data, status) {alert("failed to get product view = "+status); });
},
How can i register the map and reduce blocks on every launch ??
i m querying the view from service with angularjs like this :
How can i register the map and reduce blocks on every launch ??
Oh, this is a PhoneGap app? So you're using a native map function just for performance?
yes it is : a PhoneGap application and native view for performance
How can i register the map and reduce blocks on every launch ??
Well, you already are, aren't you? That's the Objective-C code you posted in the first message. They have to be registered for the view to work at all. Make sure they're getting registered right after the CBLDatabase is opened.
I registered the views after opening the CBLDatabase .
But why i still have the same problem when i insert new doc and i quered the view from JS, the result is not updating. So i have to reopen the app to have the view updated !!
On Apr 4, 2014, at 8:26 AM, nadia echi <echi...@gmail.com> wrote:Can you show the code that opens the database and registers the views?
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
CBLManager *manager = [CBLManager sharedInstance];
//[CBLView setCompiler: [[[CBLJSViewCompiler alloc] init] autorelease]];
// create a database
NSError *error;
self.database = [manager createDatabaseNamed: @"catafoto" error: &error];
if (!self.database)
NSLog(@"Couldn't open database (error=%@)" ,error);
NSURL *url =manager.internalURL;
//********** customer View search:
CBLView* view = [self.database viewNamed: @"client/docView"];
[view setMapBlock: ^(NSDictionary* doc, void (^emit)(id key, id value)) {
NSString* type = [doc objectForKey: @"type"];
NSArray * value = [NSArray arrayWithObjects:
[doc objectForKey: @"id"],
[doc objectForKey: @"description1"],
nil];
if ([type isEqualToString:@"CLIE"]) emit([doc objectForKey:@"_id"], value);
} version: @"1.0"];
//*********** product varianty
view = [self.database viewNamed: @"prodVersion/docView"];
[view setMapBlock: ^(NSDictionary* doc, void (^emit)(id key, id value)) {
NSString* type = [doc objectForKey: @"type"];
NSArray * value1 = [NSArray arrayWithObjects:
[doc objectForKey: @"code"],
[doc objectForKey: @"id"],
[doc objectForKey: @"versionCode"],
nil];
if ([type isEqualToString:@"product"]) emit([doc objectForKey:@"_id"], value1);
} version: @"1.0"];
......ect
(6) Reopen app ----> mean i killed the process and relaunch it : with this i can found my list updated