Open peritus opened 9 years ago
CouchDB, and so PouchDB, always responds with id and rev on successful document updates:
{
"id": "SpaghettiWithMeatballs",
"ok": true,
"rev": "2-790895a73b63fb91dd863388398483dd"
}
I suggest to rewrite the parse
functions in a way that they are non-destructive.
Please reopen if still an issue
Hey. Thanks for backbone-pouch, everything is very smooth so far :)
I'm porting an application that saves the models on a remote server via Backbone's XHR to PouchDB and backbone-pouchdb. In the current version, save() sends the complete JSON representation to the server and retrieves a complete JSON representation back from the server (I guess that's custom to my application, but I believe that is a nice REST architecture and allows the server to also change the document).
So, in
Model.parse
, my code (quoting http://backbonejs.org/#changelog 's 1.1.0 section here)With backbone-pouchdb, however, the
data
argument forparse
is always an object containing just_id
and_rev
, without the attributes that have just been saved, because of these lines:I'd propose to respond with this instead:
so the model doesn't think the the server (or PouchDB in this case) deleted all the attributes.
Also, one could argue to only call
model.toJSON()
once, but I wanted to discuss in general this first before making optimizations.