update()

Update a token.

Signature

update(object: {*: Any}): <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.

Parameters

Parameter Type Required Description

object

Object

Yes

Object with the updated document fields.

Return value

Type Description

Document

Document with updated fields.

Examples

Token.byId("371233004820889634")!.update({
  data: {
    foo: 'bar'
  }
})
{
  id: "371233004820889634",
  coll: Token,
  ts: Time("2099-07-28T03:21:08.580Z"),
  document: Customer.byId("370723013175279650"),
  data: {
    foo: "bar"
  }
}

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!