key.update()

Update a key.

Signature

update(object: {*: Any}) => <Key>

Description

The update() method updates the document with the object fields and returns the updated document. Use the update() method to rename a key or update its user-defined metadata. 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.

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

Parameters

Parameter Type Required Description

object

Object

Yes

Object with the updated document fields.

Return value

Type Description

Document

Document with updated fields.

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!