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#updateAll

DS#updateAll(resourceName, attrs[, params][, options])

The "U" in "CRUD". Update the items of type resourceName described by params with attrs and inject the result into
the data store. This is useful when you want to update items that aren't already in the data store, or you don't want
to update the items that are in the data store until the adapter operation succeeds.

Returns a promise.

Arguments
nametypedescription
resourceNamestringThe name of the resource to use. Unnecessary if using the resource directly.
attrsobjectThe attributes with which to update the items.
paramsobjectQuery parameters for selecting which items to update. Default: {}.
optionsobjectConfiguration options. Also passed through to the adapter and (conditionally) to DS.inject.
options.adapterstringOverride the default adapter.
options.cacheResponsebooleanInject the result into the store. Default: true.
Examples
Document.find({
  ext: 'htm'
}).then(function (documents) {
  documents[0].ext; // 'htm'

  // See Method Variants section below for different ways to call DS#updateAll
  return Document.updateAll({ ext: 'html' }, { ext: 'htm' });
}).then(function (documents) {
  documents[0].ext; // 'html'
});

👍

Method Variants

You can call DS#updateAll in 2 ways:

  • DS#updateAll(resourceName, attrs [,params] [, options]);
  • Resource#updateAll(attrs [, 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#updateAll


DS#updateAll(resourceName, attrs[, 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.