Role.firstWhere()
Get the first matching accessible role.
Signature
Role.firstWhere(predicate: () => Boolean)): Role | NullRole
Role.firstWhere(predicate: (val: Role) => Boolean)): Role | NullRole
Description
Each role in a Fauna is represented by a Role
document. This method returns
a Role
for the first accessible role that matches the predicate function.
Parameters
Examples
{
name: "manager",
coll: Role,
ts: Time("2023-07-27T22:40:32.735Z"),
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!