What options are there, if any, for controlling what the _id for a
document connected to a CBLModel is?
Doesn't idForNewDocumentInDatabase: get called by CBL? I overrode it in my CBLModel subclass but it never gets called.
+ (Claim *) save:(NSMutableDictionary *)dictionary {
NSLog(@"%@", dictionary);
BOOL encrypted = [dictionary objectForKey:@"data"] != nil;
CBLDocument *doc = [self saveCBLDocument:dictionary encrypted:encrypted];
return [Claim modelForDocument:doc];
}
It looks like I will have to create the CBLModel before I create the CBLDocument so that it will pick up the overridden version of idForNewDocumentInDatabase:. Yes?
CBLDocument* doc = [app.database documentWithID:couchId];
NSError *error;
// if I take these two lines out, the putProperties fails
[d removeObjectForKey:@"_id"];
[d removeObjectForKey:@"_rev"];
if (![doc putProperties: d error: &error]) {
NSLog(@"Failed saving %@. Error: %@", [d objectForKey:@"type"], [error localizedDescription]);
}
I am also HIPAA-compliant so it 'requires' a separation of the db server from the public so I can't expose CouchDB to the public.
I have a route in my Node.js server that gives me the changes from the private CouchDB server . I track the 'lastSequenceNumber' in my app and request changes since that on launch. So I get the CouchDB data from the Node.js server and want to put it into CBL. So I have to preserve the _id and _rev properties of each document so that I can update them back on the server.