queryRecord (store, type, query) Promise
The queryRecord()
method is invoked when the store is asked for a single record through a query object.
In response to queryRecord()
being called, you should always fetch fresh data. Once found, you can asynchronously call the store's push()
method to push the record into the store.
Here is an example queryRecord
implementation:
Example
app/adapters/application.js
import DS from 'ember-data'; import Ember from 'ember'; export default DS.Adapter.extend(DS.BuildURLMixin, { queryRecord: function(store, type, query) { return new Ember.RSVP.Promise(function(resolve, reject) { Ember.$.getJSON(`/${type.modelName}`, query).then(function(data) { resolve(data); }, function(jqXHR) { reject(jqXHR); }); }); } });
Parameters:
-
store
DS.Store
-
type
subclass of DS.Model
-
query
Object
Returns:
-
Promise
- promise
Please login to continue.