Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

FindMany - error on delete #455

jfgirard opened this Issue Nov 2, 2012 · 12 comments


None yet
8 participants

jfgirard commented Nov 2, 2012

I use store.findMany to fetch a bunch of records with a single ajax request. But since I update to the latest ember-data, I get and error if I delete a record fetch this way.

 Uncaught TypeError: Cannot read property '_suspendedAssociations' of null ember-data-latest.js:362
DS.ManyArray.DS.RecordArray.extend.arrayContentWillChange ember-data-latest.js:362

see http://jsfiddle.net/yxmar/2/ for more details. Hit the Load with find Many button and then try to delete the added record.

Checking the code, I realized findMany is now private.
Fine, but what is the right way to find multiple records at once ? I don't want one ajax request per id using store.find...

My use case is to perform a spatial query (using a custom ajax) on different server which bring me a list of ids. I then use ember-data to fetch the records and the related join records.


wagenet commented Nov 15, 2012

I'm not sure why findMany is marked as private. This seems to be in error to me.


elliterate commented Nov 18, 2012

Looks like a legit bug to me. record.deleteRecord() will remove the record from any containing arrays, which includes the DS.ManyArray returned by store.findMany(). Unfortunately, DS.ManyArray assumes that it represents a hasMany association and thus has an "owner" with a _suspendAssociations flag.

I just give a try with master but no luck. First, the function store.createManyArray do not register the array properly because recordArraysForClientId(clientId) expect an integer but receive an object. Because of that, the many array won't update when I delete a record.

Screen Shot 2013-02-25 at 8 38 24 AM

If I fix it, I still get the same null error on deleteRecord : Uncaught TypeError: Cannot read property '_suspendedRelationships' of null


sly7-7 commented Apr 19, 2013

@jfgirard Is this still an issue ?

I ll test it with the latest master as soon as I can.


tchak commented Apr 19, 2013

@jfgirard findMany is private because it return a ManyArray which should only be used for relationships. You should use App.Model.find({ids: [1, 2, 3]}) in your app to fetch a list of records by id.


stefanpenner commented Apr 19, 2013

@tchak although findMany is private, is this exposing some underlying issue?

@tchak Looking at the code, https://github.com/emberjs/data/blob/master/packages/ember-data/lib/system/store.js#L435 , it looks like its calling findQuery on the adapter ? It would be nice to call findMany in case of {ids: [...]} type of hash.

Did I read properly ?


tchak commented Apr 19, 2013

@jfgirard findMany and findQuery with {ids: []} is exactly the same. Except for the loading mechanics.

@tchak for the RESTAdapter, you are absolutely right. But in my case, I have my own adapter and findMany hit the couchdb server directly while findQuery hit my nodejs server (complex queries). I suppose I could simply check in adapter.findQuery what kind of query it is and call findMany if its the {ids: []}. But it use to be easier...


wycats commented Sep 5, 2013

store.findMany was never public; it's intended for usage internally by associations, which pass in necessary state. You can use findByIds, but it just triggers a bunch of parallel finds. PRs accepted to make it use findMany if available.

@wycats wycats closed this Sep 5, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment