We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
findAll() at https://github.com/jeromegn/Backbone.localStorage/blob/master/src/sync.js#L34 returns an array which is not taken care for.
When using a model with defaults set, fetch() puts the array into the model attributes. This has multiple implications.
this:
export const Config = Model.extend({ localStorage: new LocalStorage('Config'), defaults: { foo: 'bar', } }) const config = new Config() config.set("foo":"baz") config.save() config.fetch()
results in this
>> model.attributes { "0": { "foo": "baz", "id": "b65b72ba-980f-30f5-dfc3-ae4bfb6dfb94" }, "foo": "bar", }
Since there is never an id, more arrays get added during the life of the model.
I think a possible fix could be to choose the first element returned by findAll():
try { switch (method) { case 'read': - resp = (0, _underscore.isUndefined)(model.id) ? store.findAll() : store.find(model); + resp = (0, _underscore.isUndefined)(model.id) ? store.findAll()[0] : store.find(model); break; case 'create':
The text was updated successfully, but these errors were encountered:
No branches or pull requests
findAll() at https://github.com/jeromegn/Backbone.localStorage/blob/master/src/sync.js#L34 returns an array which is not taken care for.
When using a model with defaults set, fetch() puts the array into the model attributes. This has multiple implications.
this:
results in this
Since there is never an id, more arrays get added during the life of the model.
I think a possible fix could be to choose the first element returned by findAll():
The text was updated successfully, but these errors were encountered: