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 |
timeout | number ( -1 ) | Time (in ms) during which a request will still be waited to be resolved. Set it -1 if you want to wait indefinitely |
triggerEvents | boolean ( false ) | If set to true , will trigger events even if using Embeded SDK. You should always ensure that your events/pipes does not create an infinite loop. Available since Kuzzle 2.31.0 |
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)