DS#filter(resourceName[, params][, options])

Synchronously return a filtered, sorted and limited subset of items from the data store of the type specified by resourceName according to the criteria in params.

resourceNamestringThe name of the resource to use. Unnecessary if using the resource directly.
paramsobjectQuery parameters for selecting items from the collection. Default: {}. See Query Syntax for how to filter, sort, limit and offset.
optionsobjectConfiguration options. Also passed through to DS#findAll if loadFromAdapter is true.
options.loadFromAdapterbooleanSend the query to an adapter if it has not been sent yet. Default: false.
options.allowSimpleWherebooleanTreat top-level fields on the params argument as simple "where" equality clauses. Default: true.

For many examples see the tests for DS#filter.

DS#getAll(resourceName) is a faster way of doing DS#filter(resourceName, {}).


Method Variants

You can call DS#filter in 2 ways:

  • DS#filter(resourceName[, params][, options]);
  • Resource#filter([params][, options]); // where Resource was created by DS#defineResource


Need help?

Want more examples or have a question? Ask on the Slack channel or post on the mailing list then we'll get your question answered and probably update this wiki.