emberjs/data — Issue #35: findMany does not work as expected
Author: rsaccon
Created: 2012-01-08 22:38:44+00:00
State: open

I have the following models:

App.Section = DS.Model.extend({
title: DS.attr('string'),
});

App.Document = DS.Model.extend({
name: DS.attr('string'),

sections: DS.hasMany(App.Section),
});

now I preload the documents (for App.Document.sections I set an array of section ids) and for example-purpose one of them is myActiveDocument

now I want to load the sections, but how?

if Ido App.store.findMany(App.Section, myActiveDocument.get('sections'))) it does not work. By experimentation I found out that findMany expect as second argument an array of ids, then it halfway works:

var arr = myActiveDocument.get('sections').map(function(item, index, self){ return item.get('id') });
App.store.findMany(App.Section, arr));

Now I bind my data to a view and realize that the first time I call App.store.findMany(App.Section, arr)); the view gets populated with empty elements, the second time I call it, it gets populated with the proper elements.

So I guess there is anything wrong with findMany or missing documentation on how to use it properly (and yes I have implemented the adapter and serverside for it and that part seems to be fine)