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.replace()

Learn: Keys

Replace a key.

Signature

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

Description

Replaces all fields in a key, represented as an Key document, with fields from a provided data object. Fields not present in the data object, excluding the id, coll, and ts metadata fields, are removed.

A key is a type of authentication secret used for anonymous access to a Fauna database. Unlike tokens, keys are not associated with an identity.

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

Fields for the Key document. Fields not present, excluding the id, coll, and ts metadata fields, in the object are removed.

For supported document fields, see Key collection.

The object can’t include the following metadata fields:

* id * coll * ts

Return value

Type Description

Key

Key document with replaced fields.

Examples

Key.byId("412655134325080576")!.replace({
  role: "server",
  data: {
    desc: "Server key for prod app database"
  }
})
{
  id: "412655134325080576",
  coll: Key,
  ts: Time("2099-07-28T02:25:07.910Z"),
  role: "server",
  data: {
    desc: "Server 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!