Update Couchbase Lite Doc not working

Hello,

I was storing the document in local DB as below,

NSString *docId = [NSString stringWithFormat:@"%@", [_dashBoardObj valueForKey:@"unique_id"]];
CBLMutableDocument *doc = [[CBLMutableDocument alloc] initWithID: docId];

[doc setValue:@"task_list" forKey:@"type"];
[doc setValue:_dashBoardObj  forKey:@"obj"];
[doc setString:docId forKey:@"unique_id"];
NSLog(@"%@",[doc valueForKey:@"obj"]);
NSLog(@"%@",[[doc valueForKey:@"obj"]valueForKey:@"fromEmail"]);

NSError *error;
if (![_database saveDocument:doc error:&error]){
    
}else{
    NSLog(@"Saved");
}
NSString *docId = [NSString stringWithFormat:@"%@", [_dashBoardObj valueForKey:@"unique_id"]];
CBLMutableDocument *doc = [[CBLMutableDocument alloc] initWithID: docId];

[doc setValue:@"task_list" forKey:@"type"];
[doc setValue:_dashBoardObj  forKey:@"obj"];
[doc setString:docId forKey:@"unique_id"];
NSLog(@"%@",[doc valueForKey:@"obj"]);
NSLog(@"%@",[[doc valueForKey:@"obj"]valueForKey:@"fromEmail"]);

NSError *error;
if (![_database saveDocument:doc error:&error]){
    
}else{
    NSLog(@"Saved");
}

For example, my doc ID is 1459.So i will be storing my document with a key - 1459.

Now i would like to update a string value in a document associated with a key 1459.I am using below code to update,

CBLMutableDocument* list = [[_database documentWithID: listID] toMutable];
[list setValue:name forKey:@"orginal_flag"];
NSError *error;
if (![_database saveDocument:list error:&error]){
    NSLog(@"Error");
}

In above code, listID holds 1459 (which needs to be updated), name is the one which has to be updated, probably it holds a value, something like ‘1’.I am getting a success message, but the value is not getting updated in Cocuh DB.If i try to retrieve the local DB data, getting old data instead of updated data…

Any help would be appreciated,

Thanks !!

Nothing stands out as incorrect so something else must be going on. Perhaps there is a nil value somewhere that you are not realizing. If you could put this into a project that reproduces the issue simply then I’m sure someone can get to the bottom of it.

Worked like a charm now…Thanks @borrrden