js-data

Respect Your Data

Give your data the treatment it deserves with a framework-agnostic, datastore-agnostic JavaScript ORM built for ease of use and peace of mind. Works in Node.js and in the Browser.

Get Started

DS#filter

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.

Arguments
nametypedescription
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.
Examples

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.

Updated less than a minute ago

DS#filter


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

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.