Open bredfield opened 11 years ago
Did you have a ID in your response? When not - is that the problem why it throws a error. It needs a identifier to save the object into the localStorage.
models should have id primary key. If you use MongoDB you should change response replaced _id to id
Regards, Chris
That's what I thought at first, but it seems as if all models have valid IDs (and I'm not using Mongo). Weird, I keep fooling around with it.
On Friday, January 25, 2013 at 4:33 AM, Chris wrote:
Did you have a ID in your response? When not - is that the problem why it throws a error. It needs a identifier to save the object into the localStorage.
models should have id primary key. If you use MongoDB you should change response replaced _id to id
Regards, Chris
— Reply to this email directly or view it on GitHub (https://github.com/Ask11/backbone.offline/issues/29#issuecomment-12693781).
Problem here is that the ID coming from the server may be out of your control. Backbone allows you to specify idAttribute as a property on your model to tell it what the model.id value should correspond to. I would suggest instead of assuming id is always there, check for it, and if it is not there, check if the idAttribute key is present and get the value for that, otherwise return an empty string.
I'm getting an "Uncaught TypeError: Cannot call method 'toString' of undefined" when I try to fetch a collection with an initialized storage object.
It's originating from line 356:
if (!_.include(this.storage.destroyIds.values, item.id.toString())) {
The API I'm using is REST based, and each model has an ID...do you know what else could be causing the problem? Any insight would be greatly appreciated; really looking forward to using this.