OpenVeo server API for plugins

API Docs for: 4.3.1
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. Each entity must have an identification number held in the "id" property. An entity may also have a "locked" property to make it immutable.

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

Item Index

Properties

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

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'})

  • 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

getOne

Syntax

getOne

(
  • id
  • [fields]
  • callback
)
async

Summary

Fetches an entity by its id.

Parameters:

  • id String

    The entity id

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

update

Syntax

update

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

Summary

Updates entities.

Parameters:

  • [filter] ResourceFilter optional

    Rules to filter entities 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 The number of updated entities

Properties

location

Syntax

location

String final

Summary

The location of the entities in the storage.

storage

Syntax

storage

Storage final

Summary

The provider storage.