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.

credential.replace()

Learn: Credentials

Replace a credential.

Signature

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

Description

Replaces all fields in a credential, represented as a Credential 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 credential associates a password with an identity document. You can use credentials and the credential.login() method to create tokens as part of an end-user authentication system.

Metadata fields

You can’t use this method to replace the following metadata fields:

  • id

  • coll

  • ts

Parameters

Parameter Type Required Description

data

Object

true

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

For supported document fields, see Credential collection.

The object can’t include the following metadata fields:

* id * coll * ts

Return value

Type Description

Credential

Credential document with replaced fields.

Examples

Credential.byId("412654807560487424")!.replace({
  document: Customer.byId("111"),
  password: "sekret"
})
{
  id: "412654807560487424",
  coll: Credential,
  ts: Time("2099-07-28T03:42:54.650Z"),
  document: Customer("111")
}

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!