I haven't worked with CouchDB and Backbone.js together, but I guess the workaround is the same than in this explaination.
When using the localStorage
adapter, you have to provide a localStorage
attribute on the Collection and that's the only place where you type URLs (the root one for the Collection, in fact). However, when not using this adapter and attempting to sync the model, this model needs an URL because now the Collection has none. You are right when providing a URL property to the Collection, but that's used when synchronizing the whole Collection and not when synchronizing an individual model.
To make it work you may either provide an URL for the model (remember it can be a function and not just a String) or you can use the urlRoot
attribute, and that urlRoot
is what we would understand as the "Collection's URL" (where it will append its id
). If urlRoot
was /counters
and you had a model with an id
of 1
, then the final URL (it does it for you) will be /counters/1
, for example.
Edit:
You may check this question in case you didn't, even though it isn't about CouchDB, but it may throw some light on the issue: How do I fetch a single model in Backbone?