Role.all()

Learn: Roles

Get the Set of all roles.

Signature

Role.all() => Set<Role>

Description

This method returns the Set of all roles in the database. If Role.all() is the last expression in a query, the first page of the Set<Role> is returned.

Staged schema

If a database has staged schema, this method interacts with the database’s staged schema, not the active schema.

Parameters

None

Return value

Type Description

Set<Role>

A Set of Role objects for each role in the current database.

Examples

Role.all()
{
  data: [
    {
      name: "manager",
      coll: Role,
      ts: Time("2099-10-28T16:14:20.640Z"),
      privileges: [
        {
          resource: "OrderItem",
          actions: {
            create: true,
            read: true,
            write: true,
            delete: true
          }
        },
        {
          resource: "Customer",
          actions: {
            read: true
          }
        },
        {
          resource: "Manager",
          actions: {
            read: "(doc) => Query.identity() == doc && Date.today().dayOfWeek < 6"
          }
        },
        {
          resource: "getOrCreateCart",
          actions: {
            call: true
          }
        },
        {
          resource: "checkout",
          actions: {
            call: <<-END
              (args) => {
                let order = Order.byId(args[0])!
                order?.customer == Query.identity()
              }
            END
          }
        }
      ],
      membership: [
        {
          resource: "Manager"
        },
        {
          resource: "User",
          predicate: "(user) => user.accessLevel == \"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!