UPDATE
Last updated
Was this helpful?
Last updated
Was this helpful?
This method allows you to partially update (providing a few properties) or completely replace an entity in the Datastore. It will first fetch the entity, then update its data with the new ones and finally save the data back to the Datastore. The whole operation occurs inside a . Note: This method is different than using `Entity.save(null, { method: 'update' })` (which correspond to the ).
This method accepts the following arguments:
@Returns -- an entity instance.
Example
options properties
dataloader (a Dataloader instance)
replace (Boolean. default: false)
replace If you set it to true gstore will replace the the entity data in the Datastore without merging the data first. By default, MyModel.update()
does 2 operations inside one transaction:
get() the entity and merges its data with the new data
save() the entity
If you just want to override the entity data without doing any merge set replace to true in the options parameter.
dataloader The dataloader instance must be created on each request. for more information on this.
The dataloader instance will be added to the entity instance being saved. This means that it is available in your "pre" save middlewares (attached on the "this" scope (const dataloader = this.dataloader;
))