ember-batch-request icon indicating copy to clipboard operation
ember-batch-request copied to clipboard

Allow to get records in batch

Open GCorbel opened this issue 8 years ago • 2 comments

Hi,

I think it can be super useful to do batch get requests. Specially for has many relationships loading.

What you think?

GCorbel avatar May 22 '17 22:05 GCorbel

@GCorbel we tend to use coalesce requests for that usually.

// app/adapters/application.js

import JSONAPIAdapter;

export default JSONAPIAdapter.extend({
  coalesceFindRequests: true
});

shishirmk avatar May 22 '17 22:05 shishirmk

@shishirmk That's very cool. I didn't know that option. It's very useful.

It can still be useful. I sometimes do this kind of code :

  model() {
    return Ember.RSVP.hash({
      allCourses: this.store.findAll('course'),
      allSessions: this.store.query('session', { include_archives: true }),
      taxes: this.store.findAll('tax'),
      fees: this.store.findAll('fee'),
      affiliations: this.store.findAll('affiliation'),
      discountsByNumber: this.store.findAll('discountByNumber')
    });
  }

It do 6 requests and it can be useful to do the same in one. Even with coalesce requests, it do many request to load associations.

GCorbel avatar May 23 '17 00:05 GCorbel