rsvp.js - Ember.js: Load related multiple models -
since ember-guides explains how load mutliple models on route that
export default ember.route.extend({ model() { return ember.rsvp.hash({ songs: this.get('store').findall('song'), albums: this.get('store').findall('album') }); } });
im wondering how load related model-entries second one, loading songs albums indexed in songs if assume song model containing this
... albums: hasmany('album'), ...
how can that?
assuming adapter , json api backend support it, can say:
export default ember.route.extend({ model() { return ember.rsvp.hash({ songs: this.get('store').findall('song', { include: 'albums' }), }); } });
typically, generate get
/songs?include=albums
, tells json api backend include related album resources, according http://jsonapi.org/format/#fetching-includes.
on ember side of things, feature documented @ http://emberjs.com/blog/2016/05/03/ember-data-2-5-released.html#toc_code-ds-finder-include-code.
if above isn't option, there's no way load in 1 request without building custom endpoint , using store.pushpayload
.
Comments
Post a Comment