Database
Summary
Saves database configuration.
Constructor
Database
Syntax
Database
-
databaseConf
Summary
Parameters:
-
databaseConfObjectA database configuration object
Example:
// Example for how to use MongoDB database
var api = require('@openveo/api');
var databaseConf = {
...
};
// Create a new instance of the database
var db = api.Database.get(databaseConf);
// Prefer using OpenVeo database instance
var db = api.applicationStorage.getDatabase();
Item Index
Methods
close
Syntax
close
-
callback
Summary
Closes connection to the database.
Parameters:
-
callbackFunctionThe function to call when connection is closed
- Error The error if an error occurred, null otherwise
connect
Syntax
connect
-
callback
Summary
Establishes connection to the database.
Parameters:
-
callbackFunctionThe 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
Summary
Creates indexes for a collection.
get
Syntax
get
-
collection -
[criteria] -
[projection] -
[limit] -
callback
Summary
Gets a list of documents.
Parameters:
-
collectionStringThe collection to work on
-
[criteria]Object optionalMongoDB criterias
-
[projection]Object optionalMongoDB projection
-
[limit]Number optionalA limit number of items to retrieve (all by default)
-
callbackFunctionThe function to call when it's done
- Error The error if an error occurred, null otherwise
- Array The retrieved documents
getDatabase
Syntax
Summary
Gets an instance of a Database using the given database configuration.
Parameters:
-
databaseConfObjectA database configuration object
Returns:
A Database instance
getIndexes
Syntax
getIndexes
-
collection -
callback
Summary
Gets the list of indexes for a collection.
getStore
Syntax
getStore
-
collection
Summary
Gets an express-session store for the database.
Parameters:
-
collectionStringThe collection to work on
Returns:
An express-session store
increase
Syntax
increase
-
collection -
filter -
data -
callback
Summary
increase values in several documents from collection.
insert
Syntax
insert
-
collection -
data -
callback
Summary
Inserts several documents into a collection.
remove
Syntax
remove
-
collection -
filter -
callback
Summary
Removes several documents from a collection.
removeCollection
Syntax
removeCollection
-
collection -
callback
Summary
Remove a collection from the database
removeProp
Syntax
removeProp
-
collection -
property -
filter -
callback
Summary
Removes a property on all documents in the collection.
renameCollection
Syntax
renameCollection
-
collection -
target -
callback
Summary
Renames a collection.
search
Syntax
search
-
collection -
[criteria] -
[projection] -
[limit] -
[page] -
[sort] -
callback
Summary
Gets an ordered list of documents by page.
Parameters:
-
collectionStringThe collection to work on
-
[criteria]Object optionalMongoDB criterias
-
[projection]Object optionalMongoDB projection
-
[limit]Number optionalThe maximum number of expected documents
-
[page]Number optionalThe expected page
-
[sort]Object optionalA sort object
-
callbackFunctionThe function to call when it's done
- Error The error if an error occurred, null otherwise
- Array The list of documents
- Object Pagination information
update
Syntax
update
-
collection -
filter -
data -
callback
Summary
Updates several documents from collection.