user.get('posts')should resolve as soon as the ids are known, possibly before the records are loaded;user.get('posts').objectAt(0)should return aPromiseObjectand also fetch that object;- The fetches from #2 should be coalesced and;
user.get('posts').load()should fetch the records and return a promise that resolves when they are all loaded.
We want to be able to modify hasMany memberhips without loading the records, at least in the non-link case. For instance
user.get('posts').then(function (posts) {
posts.pushObject(post);
})should not need to actually fetch all of the user's posts.
To this end, the PromiseArray returned by a hasMany CP should:
- Only guarantee that ids and length are loaded upon fulfillment (not necessarily the records themselves) and 2
- Return
PromiseObjects onobjectAtand fetch those objects. These fetches would need to be coalesced to avoid n+1 queries.
user.get('posts').then(function (posts) {
posts.objectAt(0).get('isFullfilled') // => false
posts.objectAt(0).then(function (post) {
// post is loaded
});
});To make it easier to deal with cases where the entire association is needed, we
propose adding load on PromiseArray which is analogous to RSVP's all (it
is only not called all as its semantics differ enough from store.all that
this would be confusing).
// load will actually fetch the posts
user.get('posts').load().then(function (posts) {
posts.objectAt(0).get('isFulfilled') // => true
})