OpenVeo server API for plugins

API Docs for: 7.0.0
Show:

EntityProvider

Summary

Defines a provider holding a single type of resources.

An entity provider manages a single type of resources. These resources are stored into the given storage / location.

Constructor

EntityProvider

Syntax

EntityProvider

(
  • storage
  • location
)

Summary

Parameters:

  • storage Storage

    The storage to use to store provider entities

  • location String

    The location of the entities in the storage

Methods

add

Syntax

add

(
  • entities
  • [callback]
)
async

Summary

Adds entities.

Parameters:

  • entities Array

    The list of entities to store

  • [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 entities inserted
    • Array The list of added entities

executeCallback

Syntax

executeCallback

(
  • [callback]
  • [error]
  • [callback]
)

Summary

Executes the given callback or log the error message if no callback specified. It assumes that the second argument is the error. All arguments, except the callback itself, will be specified as arguments when executing the callback.

Parameters:

  • [callback] Function optional
    The function to execute
  • [error] Error optional
    An eventual error to pass to the callback
  • [callback] Function optional
    The function to call, if not specified the error is logged

get

Syntax

get

(
  • [filter]
  • [fields]
  • [limit]
  • [page]
  • [sort]
  • callback
)
async

Summary

Fetches entities.

Parameters:

  • [filter] ResourceFilter optional

    Rules to filter entities

  • [fields] Object optional

    Fields to be included or excluded from the response, by default all fields are returned. Only "exclude" or "include" can be specified, not both

    • [include] Array optional

      The list of fields to include in the response, all other fields are excluded

    • [exclude] Array optional

      The list of fields to exclude from response, all other fields are included. Ignored if include is also specified.

  • [limit] Number optional

    A limit number of entities to retrieve (10 by default)

  • [page] Number optional

    The page number started at 0 for the first page

  • [sort] Object optional

    The list of fields to sort by with the field name as key and the sort order as value (e.g. {field1: 'asc', field2: 'desc', field3: 'score'})

  • callback Function

    The function to call when it's done

    • Error The error if an error occurred, null otherwise
    • Array The list of retrieved entities
    • Object Pagination information
      • Number limit The specified limit
      • Number page The actual page
      • Number pages The total number of pages
      • Number size The total number of entities

getAll

Syntax

getAll

(
  • [filter]
  • [fields]
  • sort
  • callback
)
async

Summary

Gets all entities from storage iterating on all pages.

Parameters:

  • [filter] ResourceFilter optional

    Rules to filter entities

  • [fields] Object optional

    Fields to be included or excluded from the response, by default all fields are returned. Only "exclude" or "include" can be specified, not both

    • [include] Array optional

      The list of fields to include in the response, all other fields are excluded

    • [exclude] Array optional

      The list of fields to exclude from response, all other fields are included. Ignored if include is also specified.

  • sort Object

    The list of fields to sort by with the field name as key and the sort order as value (e.g. {field1: 'asc', field2: 'desc', field3: 'score'})

  • callback Function

    Function to call when it's done with:

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

getOne

Syntax

getOne

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

Summary

Fetches an entity.

If filter corresponds to more than one entity, the first found entity will be the returned one.

Parameters:

  • [filter] ResourceFilter optional

    Rules to filter entities

  • [fields] Object optional

    Fields to be included or excluded from the response, by default all fields are returned. Only "exclude" or "include" can be specified, not both

    • [include] Array optional

      The list of fields to include in the response, all other fields are excluded

    • [exclude] Array optional

      The list of fields to exclude from response, all other fields are included. Ignored if include is also specified.

  • callback Function

    The function to call when it's done

    • Error The error if an error occurred, null otherwise
    • Object The entity

remove

Syntax

remove

(
  • [filter]
  • [callback]
)
async

Summary

Removes entities.

Parameters:

  • [filter] ResourceFilter optional

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

removeField

Syntax

removeField

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

Summary

Removes a field from entities.

Parameters:

  • field String

    The field to remove from entities

  • [filter] ResourceFilter optional

    Rules to filter entities to update

  • [callback] Function optional

    The function to call when it's done

    • Error The error if an error occurred, null otherwise
    • Number The number of updated entities

updateOne

Syntax

updateOne

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

Summary

Updates an entity.

Parameters:

  • [filter] ResourceFilter optional

    Rules to filter the entity to update

  • data Object

    The modifications to perform

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

Properties

location

Syntax

location

String final

Summary

The location of the entities in the storage.

storage

Syntax

storage

Storage final

Summary

The provider storage.