Role document definition
Learn: Roles |
---|
We recommend you use FSL to create and update user-defined roles. See Role schema. |
A role document definition is an FQL version of an FSL role schema.
{
name: "customer",
coll: Role,
ts: Time("2099-07-31T12:37:05.280Z"),
privileges: [
{
resource: "Product",
actions: {
read: true
}
},
{
resource: "Order",
actions: {
read: "(ref) => Query.identity() == ref.customer"
}
},
{
resource: "Customer",
actions: {
read: "(ref) => Query.identity() == ref"
}
},
{
resource: "getOrCreateCart",
actions: {
call: "(id) => Query.identity()?.id == id"
}
},
{
resource: "checkout",
actions: {
call: "(name) => true"
}
}
],
membership: [
{
resource: "Customer"
}
],
data: {
desc: "End user customer role"
}
}
Fields
Field name | Value type | Description |
---|---|---|
|
(required) Unique name for the role in the database. +
Must begin with a letter. Can only include letters, numbers, and underscores.
|
|
|
(optional) Assigns the role to tokens based on the token’s identity document. See Membership definition. |
|
|
(optional) Allows one or more actions on a resource. See Privileges definition. |
|
|
The |
|
|
Timestamp of the most recent document write. |
|
|
(optional) Arbitrary user-defined metadata. |
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!