janmonschke / backbone-couchdb

A couchdb connector for backbone with support for real time changes.

Home Page:http://janmonschke.com/projects/backbone-couchdb.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

model destroyed: update collection via _changes?

gr2m opened this issue · comments

Sorry if my question is dump, I'm new to CouchDB.

I would like to build an own app based on the (much appreciated) chat example app.
While I see live updates when someone creates a new model in a collection (e.g. Messages), I don't know how to achieve the same when a model of a collection gets destroyed.

Any thoughts?

Hey,

Normally remote deletion of models should work out of the box. When a model with the same _id is being deleted, the deletion should propagate via the _changes feed and then the connector would delete the model and fire the remove event.
Since I just recently rewrote the connector and dumbly did not add tests for remote changes, it could be that it does not work at the moment. I will have a look at it tomorrow. But it worked in the last version of the ocnnector ;)

/Jan

Thanks for your quick reply, Jan! I'd love to help out, writing the test and fixing it if necessary, but at the moment, I do not really know where to start ... I'll try it at least, but I'd very appreciate if you could have a look at it, thanks!

fyi, there also seems to be a failing test with read collection with custom view

Just altered the example chat example so that you can delete your own posts and they will propagate through the _changes feed. Just forgot to add another option in chat_example/filters/messages.js. Should work fine now.
All tests pass on my machine but the tests fail on the online version. Maybe it's a CouchDB version problem.
Still using CouchDB 1.0.2 on my machine.

Added the comments example from the previous versions. It shows much simpler how remote updates work.