OpenVeo Core server

API Docs for: 7.0.0
Show:

GroupProvider

Extends EntityProvider
Module: core-providers

Summary

Defines a GroupProvider to get and save content groups.

Constructor

GroupProvider

Syntax

GroupProvider

(
  • database
)

Summary

Parameters:

  • database Database

    The database to interact with

Methods

add

Syntax

add

(
  • groups
  • [callback]
)
async

Summary

Adds content groups.

This will execute core hook "GROUPS_ADDED" after adding groups with:

  • Array The list of added groups

Parameters:

  • groups Array

    The list of groups to store with for each group:

    • String [id] The group id, generated if not specified
    • String name The group name
    • String description The group description
  • [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 groups inserted
    • Array The list of added groups

createGroupPermissions

Syntax

createGroupPermissions

(
  • id
  • name
)
Object

Summary

Creates permissions for a group.

Parameters:

Returns:

Object:

The group permissions

createIndexes

Syntax

createIndexes

(
  • callback
)
async

Summary

Creates groups indexes.

Parameters:

  • callback Function

    Function to call when it's done with :

    • Error An error if something went wrong, null otherwise

generateGroupPermissions

Syntax

generateGroupPermissions

(
  • callback
)
async

Summary

Generates permissions using groups.

Permission's translation keys for name and description are generated using the formats "GROUP_{OPERATION}NAME" and "{GROUP}{OPERATION}_DESCRIPTION".

Parameters:

  • callback Function

    Function to call when it's done with:

    • Error An error if something went wrong, null otherwise
    • Array The list of group permissions

Example:

   // Example of generated groups
   // [
   //   {
   //     label: 'My group name',
   //     permissions: [
   //       {
   //         id : 'get-group-groupID',
   //         name : 'CORE.PERMISSIONS.GROUP_GET_NAME',
   //         description : 'CORE.PERMISSIONS.GROUP_GET_DESCRIPTION'
   //       },
   //       {
   //         id : 'update-group-groupID',
   //         name : 'CORE.PERMISSIONS.GROUP_UPDATE_NAME',
   //         description : 'CORE.PERMISSIONS.GROUP_UPDATE_DESCRIPTION'
   //       },
   //       {
   //         id : 'delete-group-groupID',
   //         name : 'CORE.PERMISSIONS.GROUP_DELETE_NAME',
   //         description : 'CORE.PERMISSIONS.GROUP_DELETE_DESCRIPTION'
   //       }
   //     ]
   //   }
   // ]

});

remove

Syntax

remove

(
  • [filter]
  • [callback]
)
async

Summary

Removes groups.

This will execute core hook "GROUPS_DELETED" after deleting groups with:

  • Array ids The list of deleted group ids

Parameters:

  • [filter] ResourceFilter optional

    Rules to filter groups 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 groups

updateOne

Syntax

updateOne

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

Summary

Updates a group.

This will execute core hook "GROUP_UPDATED" after updating group with:

  • Object The hook data with:
    • String id The id of updated group
    • Object modifications The list of modifications applied

Parameters:

  • [filter] ResourceFilter optional

    Rules to filter the group to update

  • data Object

    The modifications to perform

    • [name] String optional

      The group name

    • [description] String optional

      The group description

  • [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