role.replace()
Learn: Roles |
---|
We recommend you use FSL to create and update user-defined roles. See Role schema. |
Replace a role.
Description
The replace()
method replaces a role with the object supplied. This
method removes any fields on the existing role that aren’t supplied by the
object, with some exceptions. The immutable metadata fields coll
and ts
aren’t removed and can’t be replaced.
The object must include the required fields.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
data |
Yes |
Object describing the role. |
data fields
Name | Type | Required | Description |
---|---|---|---|
name |
Yes |
Unique name. |
|
privileges |
Yes |
One or more privilege configuration objects. See Privileges definition. |
|
membership |
One or more membership configuration objects. See Membership definition. |
||
data |
User-defined metadata that stores supplemental information. |
Examples
Role.byName("manager")?.replace({
name: "manager",
privileges: [
{
resource: "Store",
actions: {
create: true,
read: true,
write: true,
delete: true
}
},
{
resource: "Manager",
actions: {
read: "(ref) => Query.identity() == ref"
}
}
],
membership: [
{
resource: "Manager"
}
]
})
{
name: "manager",
coll: Role,
ts: Time("2099-07-27T22:38:33.860Z"),
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!