CreateRole
CreateRole( param_object )
Description
CreateRole
creates a new user-defined role with the specified
param_object
. This function requires an admin key for authentication.
Parameters
Argument | Type | Definition and requirements |
---|---|---|
|
Object |
The param_object fields are described below. |
param_object
Field name | Field type | Definition and requirements |
---|---|---|
|
The role’s name. |
|
|
One or more privilege configuration objects. |
|
|
Optional. One or more membership configuration objects. |
|
|
Optional - Contains user-defined metadata for the role. It is provided for the developer to store role-relevant information. |
Returns
An object containing the metadata about the results of CreateRole
operations.
Field name | Field type | Definition and requirements |
---|---|---|
|
The reference is an automatically-generated, unique identifier within the database to the role that was created. |
|
|
The timestamp, with microsecond resolution, associated with the creation of the role. |
|
|
The role’s name. |
|
|
The role’s privileges configuration. |
|
|
The role’s membership configuration. |
Examples
The following query creates a role that grants unrestricted read access
to the spells
collection:
client.query(
q.CreateRole({
name: 'new-role',
privileges: {
resource: q.Collection('spells'),
actions: { read: true },
},
})
)
.then((result) => console.log(result))
{
ref: ref(id = "new-role", collection = ref(id = "roles")),
ts: 1526674566835735,
name: "new-role",
privileges: {
resource: ref(id = "spells", collection = ref(id = "collections")),
actions: { read: true }
}
}
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!