Module: roles-dal

Members

(static) getSpecificById

Returns a specific role by its id
Source:

Methods

(static) addParentRole(role, parentRole) → {Promise.<(Object|Error)>}

Changes the parent role of the given Role, the parentRole parameter should be an object containing a field role which contains the name of the parent role and field id which contains the id of the parent role, the parameter role should be an object containing a field role with the role name and a field id with the role's id. Ex: role.addParentRole({role:'develloper',id:3},{role:'admin',id:1});
Parameters:
Name Type Description
role string
parentRole int
Source:
Returns:
Type
Promise.<(Object|Error)>

(static) create(role) → {Promise.<void>}

Creates a new role with a possible role Hierarchy, if the role already exists returns the existing one.
Parameters:
Name Type Description
role string
Source:
Returns:
Type
Promise.<void>

(static) delete(roleId) → {Promise.<void>}

Delete a specific role by its roleId
Parameters:
Name Type Description
roleId int
Source:
Returns:
Type
Promise.<void>

(static) get() → {Promise.<void>}

Returns all roles
Source:
Returns:
Type
Promise.<void>

(static) getByName(roleName) → {Promise.<(Object|Error)>}

Returns a role by its name
Parameters:
Name Type Description
roleName string
Source:
Returns:
Type
Promise.<(Object|Error)>

(static) getWithParents() → {Promise.<(Object|Error)>}

Returns all roles that own a parent_role
Source:
Returns:
Type
Promise.<(Object|Error)>

(static) update(id, parent_role) → {Promise.<{insertedRows: (Object|Error), parent_role: *}>}

Changes the parent role of the Role specified by the id, the parent_role parameter should be an object containing a field label which contains the name of the parent role and field value which contains the id of the parent role. Ex: role.update(3,{label:'admin',value:1});
Parameters:
Name Type Description
id int
parent_role int
Source:
Returns:
Type
Promise.<{insertedRows: (Object|Error), parent_role: *}>