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

Replace an key.

Signature

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

Description

The replace() method replaces keys with the document supplied. This method removes any fields not supplied by the document, with some exceptions. The immutable metadata fields id, coll and ts aren’t removed and can’t be replaced.

The document must include the required fields.

Parameters

Parameter Type Required Description

object

Object

Yes

Object with the replacement document fields.

Return value

Type Description

Document

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!