Skip saving specific properties


I have an Objective-C class - UserProfile - that inherits from CBLModel. It has several @synthesize fields that I don’t want to persist to Couchbase Lite; they are annotated that way for legacy reasons.

How do I specify those fields be left out during an object save?


Hey @boscomonkey,

You may first define the keys from the Profile by looking at its

Then can simply leave the fields out when you create your new object that will contain the object map of keys-values.

//Define the new document’s properties:
NSDictionary *doc = @{@“inherit_text”: textField.text,
@“check”: @NO,
@“created_at”: [CBLJSON JSONObjectWithDate[NSDate date]]};

Upon creating the object, you then specify the database and save the object into the document. In Objective-C, the HashMap object is a NSMutableDictionary where below

NSMutableDictionary* updatedProperties = [ mutableCopy];
updatedProperties[@“new item”] = @“adding new entry into existing document”;
updatedProperties[@“inherit_text”] = @“text to save”;

Then can save the document back into the database.

// Save the document:
CBLDocument *doc = [_database createDocument];
NSError *error;
if ([doc putProperties: document error: &error]) {
    textField.text = nil;
} else {
    AppDelegate *app = [[UIApplication sharedApplication] delegate];
    [app showMessage:@"Couldn't save new item" withTitle:@"Error"];

You may reference the guide here as well for further reading.