ID of the model to create or update
Function called to update the model. Should return the model after making modifications to it.
Creates or updates a model using the given function. The function will be retried automaticaly in case a conflict happens, so could be called multiple times.
You can return the AbortUpdate
symbol to cancel the operation and
return nothing.
ID of the model to create or update
Function called to update the model. Should return the model after making modifications to it.
Call options
Finds the model identified by the partition ID, or creates it if it does not exist. You may pass in an instance of a model, or a function that creates an instance of the model.
Updates a model using the given function. The function will be retried automaticaly in case a conflict happens, so could be called multiple times.
Note that when calling this, the properties that were previously on
the model may be re-set if the model is reread from the database
as a result of a conflict. Therefore, you should make sure to have all
mutations happen inside the updateFn
method, not before it.
The update function should return the model when it's ready run the update,
or undefined
to cancel the operation.
For example, this will atomically update the number of views on a Page document:
await atomic.update(Page.partition(pageId), pageId, async existing => {
page.views++;
return page;
});
Function called to update the model. Should return the model after making modifications to it.
Call options
Generated using TypeDoc
Creates or updates a model using the given function. The function will be retried automaticaly in case a conflict happens, so could be called multiple times. This similar to an "upsert" operation.
For example, this will create a new
PageView
instance if it doesn't exist, or update the number of views if it does:Cosmos.ErrorResponse if the IAtomicOptions.retries are exhausted.