update Method - Service Factory Reference
This method updates one or more records of the data model.
Update One Record#
Parameters#
To update one record, pass an object that at least has an id
property, identifying the ID of the record to update.
You can pass in the same object any other properties to update.
Returns#
The method returns the updated record as an object.
Update Multiple Records#
Parameters#
To update multiple records, pass an array of objects. Each object has at least an id
property, identifying the ID of the record to update.
You can pass in each object any other properties to update.
Returns#
The method returns an array of objects of updated records.
Update Records Matching a Filter#
Parameters#
To update records that match specified filters, pass as a parameter an object having two properties:
selector
: An object of filters that a record must match to be updated.data
: An object of the properties to update in every record that match the filters inselector
.
In the example above, you update the published_at
property of every post record whose name is My Post
.
Returns#
The method returns an array of objects of updated records.
Multiple Record Updates with Filters#
Parameters#
To update records matching different sets of filters, pass an array of objects, each having two properties:
selector
: An object of filters that a record must match to be updated.data
: An object of the properties to update in every record that match the filters inselector
.
In the example above, you update the published_at
property of post records whose name is My Post
, and update the metadata
property of post records whose name is Another Post
.
Returns#
The method returns an array of objects of updated records.