Skip to content
New issue

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 returns empty array on a first call when using DSLocalStorageAdapter #234

Closed
sergproua opened this issue Nov 9, 2014 · 1 comment

Comments

@sergproua
Copy link

Parent.findAll returns empty array on a first call. It only happens when resource has relationships defined. I'm using DSLocalStorageAdapter.

http://jsfiddle.net/2dwyh7qr/3/

@sergproua sergproua changed the title findAll returns empty array on a first call when using LocalStorageDS findAll returns empty array on a first call when using DSLocalStorageAdapter Nov 9, 2014
@jmdobry
Copy link
Member

jmdobry commented Nov 9, 2014

You actually found a bug in the update method of the DSLocalStorageAdapter, which I will fix.

The reason this is happening is that the upsert option for DS.create defaults to true, which means that if you include a primary key in the attributes that you pass to DS.create, it will instead try to update the existing item that has that primary key.

Change your jsfiddle example to either use upsert: false or not provide primary keys, and it should work fine. If you don't provide primary keys then guids will be created for you.

@jmdobry jmdobry closed this as completed Nov 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants