token.update()

Learn: Tokens

Update a token.

Signature

update(data: { *: Any }) => Token

Description

Updates a token's metadata or identity document represented as an Token document, with fields from a provided data object.

During the update, fields from the data object are copied to the document, creating new fields or updating existing fields. The operation is similar to a merge.

A token is a type of authentication secret used to provide identity-based access to a Fauna database.

Nested fields

Fields with nested objects in the data object are merged with the identically named nested object in the document.

Remove a field

To remove a document field, set its value in the data object to null.

Metadata fields

You can’t use this method to insert or edit the following metadata fields:

  • id

  • coll

  • ts

Parameters

Parameter Type Required Description

data

Object

true

Document fields for the Token document.

For supported document fields, see Token collection.

The object can’t include the following metadata fields:

* id * coll * ts

Return value

Type Description

Token

The updated Token document.

Examples

Token.byId("401670938431586381")!.update({
  data: {
    clientIpAddr: "123.123.12.1"
  }
})
{
  id: "401670938431586381",
  coll: Token,
  ts: Time("2099-07-28T03:21:08.580Z"),
  document: Customer("111"),
  data: {
    clientIpAddr: "123.123.12.1"
  }
}
\