Closed RoundSparrow closed 11 years ago
This is being handled by the use of the Ektorp api. When a checkbox is pushed in the UI, this code is eventually called:
GroceryItemUtils.toggleCheck(item);
couchDbConnector.update(item);
and as mentioned in the CouchDbConnector Ektorp Docs, it requires an existing revision number which it will use in the update. That method can also throw an exception if a conflict is detected.
Does that explain things?
ok, I think I understand the sequence.
In my application, I never do any read of existing records... only update and inserts... so my problem isn't in GrocerySync. Thank you.
Hello.
I have a question about this as a sample app in terms of instructional purpose. When I look at the code for toggleItemChecked method... I see it does a couchbase lite .update.
What I don't see is any reference to the previous _rev
From this docs page: http://guide.couchdb.org/draft/api.html
"If you want to update or delete a document, CouchDB expects you to include the _rev field of the revision you wish to change. When CouchDB accepts the change, it will generate a new revision number."
and here: https://github.com/couchbase/couchbase-lite-ios/wiki/Guide%3A-Data-Model
"The tricky bit is that, in order to save an update to an existing document, you have to include its current revision ID. If the revision ID you provide isn't the current one, the update is rejected"
Is GrocerySync doing this somewhere that I'm not observing?
Thank you