flams/emily

calling couchDBStore upload method multiple times

Closed this issue · 2 comments

Not sure if that's an intended use or if I am doing something wrong.

what I do:

  1. couchDBStore.sync(db, id)
  2. couchDBStore.set("property 1", valueA)
  3. couchDBStore.upload()

then later
4. couchDBStore.set("property 2", valueB)
5. couchDBStore.upload()

Can we call upload multiple times in a row (without "unsync'ing/resync'ing")?
Right now my code yields a db document update conflict error.

CouchDB documentation indicates that to avoid this, the latest document revision should be added to the PUT method when updating the db. Not sure that this is what upload() does.

Any thoughts?

Thanks for the bug report Vincent.
Of course, the _rev is included in the PUT request, otherwise no upload would have ever worked. Though, in your case, if the second upload is too close to the first one, the PUT request could embed the wrong _rev.
I think that I can solve this by setting the _rev field in the store before resolving the promise.
I'll let you know when the fix is ready

This issue is fixed in Emily 1.1.4