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
name | type | description |
---|---|---|
resourceName | string | The name of the resource to use. Unnecessary if using the resource directly. |
attrs | object | The attributes with which to update the items. |
params | object | Query parameters for selecting which items to update. Default: {} . |
options | object | Configuration options. Also passed through to the adapter and (conditionally) to DS.inject . |
options.adapter | string | Override the default adapter. |
options.cacheResponse | boolean | Inject 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