Groups ^v2.7.0
Creates, finds and deletes security groups.
js
const group = userSecurity.groups.get("Admin");
console.log(group.getName());Constructor
Reached through the userSecurity.groups property. It can't be created directly.
Methods
create create(name) Group
Creates a security group and returns it as a Group. The name must be unique.
| Parameter | Type | Description |
|---|---|---|
name | string | The new group's name. |
get get(name) Group | null
Returns a Group by name, or null when there's no such group.
| Parameter | Type | Description |
|---|---|---|
name | string | The group's name. |
list list() object
Returns every security group, with each group's id and name.
delete delete(name) boolean
Deletes a security group. Returns true when it was deleted, or false when there's no such group.
| Parameter | Type | Description |
|---|---|---|
name | string | The group's name. |
Examples
js
// Create a new security group
const newGroup = userSecurity.groups.create("Example Group");
console.log(newGroup.getName());
// Retrieve a security group
const group = userSecurity.groups.get("Admin");
console.log(group.getName());
// List all security groups
const groups = userSecurity.groups.list();
console.log(groups);
// Delete a security group
const deleted = userSecurity.groups.delete("Example Group");
console.log(deleted ? "Group deleted successfully." : "Group deletion failed.");Related
- Group: the group these methods return.