OpenVeo Core server

API Docs for: 7.0.0
Show:

RoleProvider

Extends EntityProvider
Module: core-providers

Summary

Defines a RoleProvider to get and save back end user roles.

Constructor

RoleProvider

Syntax

RoleProvider

(
  • database
)

Summary

Parameters:

  • database Database

    The database to interact with

Item Index

Methods

add

Syntax

add

(
  • roles
  • [callback]
)
async

Summary

Adds roles.

Parameters:

  • roles Array

    The list of roles to store with for each role:

    • String name The role name
    • Array permissions The role permissions
    • String [id] The role id, generated if not specified
  • [callback] Function optional

    The function to call when it's done

    • Error The error if an error occurred, null otherwise
    • Number The total amount of roles inserted
    • Array The list of added roles

createIndexes

Syntax

createIndexes

(
  • callback
)
async

Summary

Creates roles indexes.

Parameters:

  • callback Function

    Function to call when it's done with :

    • Error An error if something went wrong, null otherwise

remove

Syntax

remove

(
  • [filter]
  • [callback]
)
async

Summary

Removes roles.

This will execute core hook "ROLES_DELETED" after deleting roles with:

  • Array ids The list of deleted role ids

Parameters:

  • [filter] ResourceFilter optional

    Rules to filter roles to remove

  • [callback] Function optional

    The function to call when it's done

    • Error The error if an error occurred, null otherwise
    • Number The number of removed roles

updateOne

Syntax

updateOne

(
  • [filter]
  • data
  • [callback]
)
async

Summary

Updates a role.

Parameters:

  • [filter] ResourceFilter optional

    Rules to filter the role to update

  • data Object

    The modifications to perform

    • [name] String optional

      The role name

    • [permissions] Array optional

      The role permissions

  • [callback] Function optional

    The function to call when it's done

    • Error The error if an error occurred, null otherwise
    • Number 1 if everything went fine