DS.Store#query()

query (modelName, query) Promise

Defined in addon/-private/system/store.js:1076
Available since 1.13.0

This method delegates a query to the adapter. This is the one place where adapter-level semantics are exposed to the application.

Exposing queries this way seems preferable to creating an abstract query language for all server-side queries, and then require all adapters to implement them.

If you do something like this:

store.query('person', { page: 1 });

The call made to the server, using a Rails backend, will look something like this:

Started GET "/api/v1/person?page=1"
Processing by Api::V1::PersonsController#index as HTML
Parameters: { "page"=>"1" }

If you do something like this:

store.query('person', { ids: [1, 2, 3] });

The call to the server, using a Rails backend, will look something like this:

Started GET "/api/v1/person?ids%5B%5D=1&ids%5B%5D=2&ids%5B%5D=3"
Processing by Api::V1::PersonsController#index as HTML
Parameters: { "ids" => ["1", "2", "3"] }

This method returns a promise, which is resolved with an AdapterPopulatedRecordArray once the server returns.

Parameters:

modelName String
query Any
an opaque query to be used by the adapter

Returns:

Promise
promise
doc_EmberJs
2016-11-30 16:50:54
Comments
Leave a Comment

Please login to continue.