arango-util
Utilities and helper functions for arangodb.
Installation
npm install arango-util
Collection functions
collectionExists
Verify if a collection exists.
arguments
- collection: arangojs collection object
returns
A promise containing true if the collection exists, otherwise false.
example
var server = url: 'http://localhost:8529' ;var util = ; server; var collection = server; util ;
ensureCollectionExists
Verify if a collection exists. If the collection does not exists, it will be created. If the collection exists, it does nothing.
arguments
- collection: arangojs collection object
returns
A promise containing true if the collection has been created, otherwise false.
example
var server = url: 'http://localhost:8529' ;var util = ; server; var collection = server; util ;
getByKey
Gets a document by key in a specified collection. If the document is found, it is returned otherwise, null.
options
- collection: an arangojs collection object.
- key: the key of the document.
returns
A promise containing the document or null if the document is not found.
example
var server = url: 'http://localhost:8529' ;var util = ; server; var collection = server; util ;
removeByKey
Removes a document by key from a specified collection. If the document is found, it returns true, otherwise, false.
options
- collection: an arangojs collection object.
- key: the key of the document.
returns
A promise containing true if the document have been removed or false if the document already does not exists.
example
var server = url: 'http://localhost:8529' ;var util = ; server; var collection = server; util ;
Database functions
databaseExists
Verify if a database exists.
arguments
- database: an arangojs database object
returns
A promise containing true if the database exists, otherwise false.
example
var server = url: 'http://localhost:8529' ;var util = ; server; util ;
dropDatabase
Attempt to remove a database and returns true if the database have been removed, otherwise false.
arguments
- database: an arangojs database object
returns
A promise containing true if the database have been removed, otherwise false.
example
var server = url: 'http://localhost:8529' ;var util = ; server; util ;
ensureDatabaseExists
Verify if a database exists. If the database does not exists, it will be created. If the database exists, it does nothing.
arguments
- database: an arangojs database object
returns
A promise containing true if the database has been created, otherwise false.
example
var server = url: 'http://localhost:8529' ;var util = ; server; util ;
Licence
MIT License