I'm following IBM's tutorial on CouchDB and ran into a problem saving edited documents. Saving a new doc works fine, and it looks like all my existing doc's values (retrieved via the openDoc
function) are valid, but the new values are simply not taking.
As I trace through the executing code, it looks like the new values are there:
However, after saveDoc
returns successfully (strange!), the doc is not updated. If I log the updated doc, the logged object has no _id
or _rev
values, though you can clearly see they were present while saving (see first screenshot).
Is there some nuance of saveDoc
, or perhaps Evently, that I'm not understanding?
In your
success
callback, you are not logging the updated document, your are logging thenewdoc
object from line 87 (minus it went through thesaveDoc
function, which apparently undefined_id
and_rev
, but that's ok).The
success
callback can have an argument that is the response from the server. If you write :you should see in the response a new
_rev
starting with2-
.If you really want to see the full doc once updated, just call
openDoc
from yoursuccess
callback to get the updated version.Other detail, when you say
I think you meant that the
success
callback is called, becausesaveDoc
is asynchronous and should return instantly anyway.