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

Learn: Credentials

Create a credential.

Signature

Credential.create(data: { id: ID | Null, document: Ref<{ *: Any }>, password: String | Null, data: { *: Any } | Null }) => Credential

Description

Creates a credential with the provided document fields. Fauna stores credentials as documents in the Credential system collection.

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.

Parameters

Parameter Type Required Description

data

Object

true

Document fields for the new Credential document.

For supported document fields, see Credential collection.

Return value

Type Description

Credential

The new Credential document.

Examples

Credential.create({
  document: Customer.byId("111"),
  password: "sekret"
})
{
  id: "401670627820306505",
  coll: Credential,
  ts: Time("2099-06-25T13:23:31.440Z"),
  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!