Role.create()
Create a role.
Description
The Role.create()
method creates a role with the provided data.
Only resources with an admin
key can create or manage user-defined roles.
Roles are created in the current database. To establish the same roles
throughout a database hierarchy, you must separately create identical roles in
each child database that requires them.
The maximum number of overlapping roles is 64. Trying to create more overlapping roles result in an error.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
data |
Yes |
Object describing the role. |
data fields
Name | Type | Required | Description |
---|---|---|---|
name |
Yes |
A unique name. |
|
membership |
One or more membership configuration objects. |
||
privileges |
Yes |
One or more privilege configuration objects. |
|
data |
User-defined metadata that stores supplemental information. |
Examples
{
name: "storeOwner",
coll: Role,
ts: Time("2023-07-27T21:59:03.480Z"),
privileges: [
{
resource: "Order",
actions: {
create: true,
delete: true
}
},
{
resource: "Product",
actions: {
create: true
}
},
{
resource: "Manager",
actions: {
read: "(ref) => Query.identity() == ref"
}
}
],
membership: [
{
resource: "Manager"
}
],
data: {
custom: "some data"
}
}
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!