How do I save an updated CouchDB doc with Evently?

160 Views Asked by At

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:

enter image description here

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).

enter image description here

Is there some nuance of saveDoc, or perhaps Evently, that I'm not understanding?

1

There are 1 best solutions below

1
On BEST ANSWER

In your success callback, you are not logging the updated document, your are logging the newdoc object from line 87 (minus it went through the saveDoc 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 :

success: function(data) {
    console.log(data);
}

you should see in the response a new _rev starting with 2-.

If you really want to see the full doc once updated, just call openDoc from your success callback to get the updated version.


Other detail, when you say

saveDoc returns successfully

I think you meant that the success callback is called, because saveDoc is asynchronous and should return instantly anyway.