DS.Adapter#findMany()

findMany (store, type, ids, snapshots) Promise

Defined in addon/adapter.js:423

The store will call findMany instead of multiple findRecord requests to find multiple records at once if coalesceFindRequests is true.

app/adapters/application.js
import DS from 'ember-data';

export default DS.Adapter.extend({
  findMany(store, type, ids, snapshots) {
    return new Ember.RSVP.Promise(function(resolve, reject) {
      Ember.$.ajax({
        type: 'GET',
        url: `/${type.modelName}/`,
        dataType: 'json',
        data: { filter: { id: ids.join(',') } }
      }).then(function(data) {
        Ember.run(null, resolve, data);
      }, function(jqXHR) {
        jqXHR.then = null; // tame jQuery's ill mannered promises
        Ember.run(null, reject, jqXHR);
      });
    });
  }
});

Parameters:

store DS.Store
type DS.Model
the DS.Model class of the records
ids Array
snapshots Array

Returns:

Promise
promise
doc_EmberJs
2016-11-30 16:49:23
Comments
Leave a Comment

Please login to continue.