Check out v4 of the Fauna CLI

v4 of the Fauna CLI is now in beta.

The new version introduces enhancements to the developer experience, including an improved authentication workflow. To get started, check out the CLI v4 quick start.

key.update()

Learn: Keys

Update a key.

Signature

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

Description

Updates a key, represented as an Key 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.

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 Key document.

For supported document fields, see Key collection.

The object can’t include the following metadata fields:

* id * coll * ts

Return value

Type Description

Key

The updated Key document.

Examples

Key.byId("412655134325080576")!.update({
  data: {
    desc: "Admin key for prod app database"
  }
})
{
  id: "412655134325080576",
  coll: Key,
  ts: Time("2099-07-11T14:17:49.890Z"),
  role: "admin",
  data: {
    desc: "Admin key for prod app database"
  }
}

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!