OpenVeo server API for plugins

API Docs for: 7.0.0
Show:

Database

Summary

Defines base database for all databases.

This should not be used directly, use one of its subclasses instead.

Constructor

Database

Syntax

Database

(
  • configuration
)

Summary

Parameters:

  • configuration Object

    A database configuration object depending on the database type

    • type String

      The database type

    • host String

      Database server host

    • port Number

      Database server port

    • database String

      The name of the database

    • username String

      The name of the database user

    • password String

      The password of the database user

Methods

add

Syntax

add

(
  • location
  • resources
  • [callback]
)
async

Summary

Adds resources to the storage.

Parameters:

  • location String

    The storage location where the resource will be added

  • resources Array

    The list of resources 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 resources inserted
    • Array The list of inserted resources

close

Syntax

close

(
  • callback
)
async

Summary

Closes connection to the database.

Parameters:

  • callback Function

    The function to call when connection is closed

    • Error The error if an error occurred, null otherwise

connect

Syntax

connect

(
  • callback
)
async

Summary

Establishes connection to the database.

Parameters:

  • callback Function

    The function to call when connection to the database is established

    • Error The error if an error occurred, null otherwise

createIndexes

Syntax

createIndexes

(
  • collection
  • indexes
  • callback
)
async

Summary

Creates indexes for a collection.

Parameters:

  • collection String

    The collection to work on

  • indexes Array

    A list of indexes using MongoDB format

  • callback Function

    The function to call when it's done

    • Error The error if an error occurred, null otherwise
    • Object Information about the operation

dropIndex

Syntax

dropIndex

(
  • collection
  • indexName
  • callback
)
async

Summary

Drops index from a collection.

Parameters:

  • collection String

    The collection to work on

  • indexName String

    The name of the index to drop

  • callback Function

    The function to call when it's done

    • Error The error if an error occurred, null otherwise
    • Object Information about the operation

get

Syntax

get

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

Summary

Fetches resources from the storage.

Parameters:

  • location String

    The storage location where to search for resources

  • [filter] ResourceFilter optional

    Rules to filter resources

  • [fields] Object optional

    Expected resource 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 resources 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 resources
    • 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 resources

getIndexes

Syntax

getIndexes

(
  • collection
  • callback
)
async

Summary

Gets the list of indexes for a collection.

Parameters:

  • collection String

    The collection to work on

  • callback Function

    The function to call when it's done

    • Error The error if an error occurred, null otherwise
    • Array The list of indexes

getOne

Syntax

getOne

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

Summary

Fetches a single resource from the storage.

Parameters:

  • location String

    The storage location where to search for the resource

  • [filter] ResourceFilter optional

    Rules to filter resources

  • [fields] Object optional

    Expected resource 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 resource

getStore

Syntax

getStore

(
  • collection
)
Store

Summary

Gets an express-session store for the database.

Parameters:

  • collection String

    The collection to work on

Returns:

Store:

An express-session store

remove

Syntax

remove

(
  • location
  • filter
  • [callback]
)
async

Summary

Removes resources from the storage.

Parameters:

  • location String

    The storage location where to find the resources to remove

  • filter ResourceFilter

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

removeCollection

Syntax

removeCollection

(
  • collection
  • callback
)
async

Summary

Removes a collection from the database.

Parameters:

  • collection String

    The collection to work on

  • callback Function

    The function to call when it's done

    • Error The error if an error occurred, null otherwise

removeField

Syntax

removeField

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

Summary

Removes a field from resources of a storage location.

Parameters:

  • location String

    The storage location where to find the resources

  • field String

    The field to remove from resources

  • [filter] ResourceFilter optional

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

renameCollection

Syntax

renameCollection

(
  • collection
  • target
  • callback
)
async

Summary

Renames a collection.

Parameters:

  • collection String

    The collection to work on

  • target String

    The new name of the collection

  • callback Function

    The function to call when it's done

    • Error The error if an error occurred, null otherwise

updateOne

Syntax

updateOne

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

Summary

Updates a resource in the storage.

Parameters:

  • location String

    The storage location where to find the resource to update

  • filter ResourceFilter

    Rules to filter the resource 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

configuration

Syntax

configuration

Object final

Summary

The storage configuration.

host

Syntax

host

String final

Summary

Database host.

name

Syntax

name

String final

Summary

Database name.

password

Syntax

password

String final

Summary

Database user password.

port

Syntax

port

Number final

Summary

Database port.

username

Syntax

username

String final

Summary

Database user name.