corrected the return type and added an example (#13724)

This commit is contained in:
Faris
2025-05-05 19:57:16 +05:30
committed by GitHub
parent b155192b39
commit 5dbb7e86a1
2 changed files with 9 additions and 6 deletions

View File

@@ -1040,7 +1040,7 @@ Object.assign(Roles, {
},
/**
* @summary Retrieve all users who are in target role.
* @summary Retrieve a cursor of all users who are in the target role.
* @memberof Roles
* @locus Anywhere
* @param {Array|String} roles Name of role or an array of roles.

View File

@@ -225,23 +225,26 @@ const customRoles = Roles.getAllRoles({
Example:
```js
// returns a cursor of all admin users
const adminUsersCursor = await Roles.getUsersInRoleAsync("admin");
// Find all admin users
const adminUsers = await Roles.getUsersInRoleAsync("admin");
const adminUsers = await (await Roles.getUsersInRoleAsync("admin")).fetchAsync();
// Find users with specific roles in a scope
const scopedUsers = await Roles.getUsersInRoleAsync(
const scopedUsers = await (await Roles.getUsersInRoleAsync(
["editor", "writer"],
"blog"
);
)).fetchAsync();
// Find users with custom options
const users = await Roles.getUsersInRoleAsync("manager", {
const users = await (await Roles.getUsersInRoleAsync("manager", {
scope: "department-a",
queryOptions: {
sort: { createdAt: -1 },
limit: 10,
},
});
})).fetchAsync();
```
## Checking Roles