Hi,
I want to clarify whether the below code is fine or anything wrong in that.
I have iOS client and Couchbase server installed. I am updating some data on the client. I am referring GrocerySync iOS sample, which has UITableview and displaying the list of document.
I have further modified and updating the document on the iOS app and send the updated document to server using the below code,
(IBAction)updateDocument:(id)sender {
CBLQueryRow *row = [dataSource rowAtIndex:selectedTableRow];
CBLDocument *doc = row.document;NSError* error;
CBLSavedRevision* newRev = [doc update:^BOOL(CBLUnsavedRevision *rev) {rev[@“studentID"] = self->studentIDFld.text; rev[@“studentName"] = self->studentNameFld.text; rev[@“teacherName"] = self->teacherNameFld.text; rev[@"description"] = self->descriptionTxtView.text; rev[@“fees”] = self->feesAmtFld.text; rev[@“deviceuser"] = self->deviceuserFld.text; return YES;
} error: &error];
if (!newRev) {
UIAlertView* error = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@“Alert”,nil)
message:NSLocalizedString(@“Failed to update item.”,nil)
delegate:nil
cancelButtonTitle:NSLocalizedString(@“Ok”,nil)
otherButtonTitles:nil ,nil];[error show];
}
}
This is pushing updated data to server without any issues. I do have push, pull and continuos replication observor sync code in iOS app.
My question is, is this way we have to manually update the data from client app to server? Because, whatever I am updating on the server side, it is getting automatically reflected on the iOS app, i didn’t do any manual insert. But, when I update the data from iOS app, Do I need to call “update” API and manually update the document data like this for each field -> (rev[@“studentID"] = self->studentIDFld.text;) ?