// Updates the document

- (BOOL) updateWorkout:(NSDictionary *) workout {

    NSError *error;


    // retrieve the document from the database

    CBLDocument *getDocument = [database documentWithID: [[workout 
objectForKey:@"workout"] objectForKey:@"workout_id"];


    // make a mutable copy of the properties from the
 document we just 
retrieved

    NSMutableDictionary *docContent = [getDocument.properties
 mutableCopy];


    // modify the document properties

    docContent[@"exercises"] = [[workout objectForKey:@"workout"] 
objectForKey:@"exercises"];
    // save the Document revision to the database

    CBLSavedRevision *newRev = [getDocument putProperties:docContent
 
error:&error];


    if (!newRev) {

        NSLog(@"Cannot update document. Error message: %@",
 
error.localizedDescription);

    }


    // display the new revision of the document

    NSLog(@"The new revision of the document contains: %@",
 
newRev.properties);


    return YES;

}

The given workout is a wrapper dictionary with a key @"workout" and the value 
is a dictionary that contains some keys-values.

This method is pretty the same as the tutorial's one.

Have I to put manually a _rev property in document at the moment of insertion?

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/856f951c-0e4a-4400-8b1f-f82795815747%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to