token.update()
Update a token.
Description
The update()
method updates the document with the object fields
and returns the updated document. During the update, fields from object
are copied to the document, creating new fields or updating existing
fields. The operation is similar to a merge.
Only the fields included in object are updated, all other document fields aren’t updated. Fields with nested objects in object are merged with the identically named nested object in the document.
Use the update()
method to rename a token or update its user-defined
metadata.
To remove a document field, set its value in object to null
. Deleted
fields aren’t saved.
Examples
Token.byId("371233004820889634")!.update({
data: {
clientIpAddr: "123.123.12.1"
}
})
{
id: "371233004820889634",
coll: Token,
ts: Time("2099-07-28T03:21:08.580Z"),
document: Customer.byId("370723013175279650"),
data: {
clientIpAddr: "123.123.12.1"
}
}
Is this article helpful?
Tell Fauna how the article can be improved:
Visit Fauna's forums
or email docs@fauna.com
Thank you for your feedback!