Role.byName()

Get a role by its name.

Signature

Role.byName(name: string): Role | NullRole

Description

Returns a Role for the given name.

Parameters

Parameter Type Required Description

name

String

Yes

Name of the Role.

Return value

One of:

Type Description

Role

A Role for the role.

NullRole

Document is non-existent or is inaccessible. See NullDoc.

Examples

Role.byName("manager")
{
  name: "manager",
  coll: Role,
  ts: Time("2023-07-21T00:22:25.260Z"),
  privileges: [
    {
      resource: "Store",
      actions: {
        create: true,
        read: true,
        write: true,
        delete: true
      }
    },
    ...
    {
      resource: "Manager",
      actions: {
        read: "(ref) => Query.identity() == ref"
      }
    }
  ],
  membership: [
    {
      resource: "Manager"
    }
  ]
}

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!