searchRoles #
Searches security roles, optionally returning only those allowing access to the provided controllers.
searchRoles([body], [options]);
Property | Type | Description |
---|---|---|
body | object | Query including allowed controllers to search for |
options | object | Query options |
body #
Property | Type | Description |
---|---|---|
controllers | array<string> | Role identifiers |
options #
Property | Type (default) | Description |
---|---|---|
queuable | boolean ( true ) | If true, queues the request during downtime, until connected to Kuzzle again |
from | number ( 0 ) | Offset of the first document to fetch |
size | number ( 10 ) | Maximum number of documents to retrieve per page |
scroll | string ( "" ) | When set, gets a forward-only cursor having its ttl set to the given value (ie 30s ; cf elasticsearch time limits) |
Resolves #
A SearchResult
object containing the retrieved Role
objects.
Usage #
try {
const results = await kuzzle.security.searchRoles({
controllers: ['auth']
});
console.log(results);
/*
RoleSearchResult {
aggregations: undefined,
hits:
[ Role { _id: 'admin', controllers: [Object] },
Role { _id: 'default', controllers: [Object] },
Role { _id: 'anonymous', controllers: [Object] } ]
fetched: 3,
total: 3 }
*/
console.log(`Successfully retrieved ${results.total} roles`);
} catch (e) {
console.error(e);
}
Edit this page on Github(opens new window)