hemera-arango-store v7.0.2
:avocado: Hemera-arango-store package
This is a plugin to use Arangodb with Hemera.
Execute any AQL query from anywhere. For more details ArangoDB Query Language
Start Arangodb with Docker
docker run -e ARANGO_NO_AUTH=1 -d --name arangodb-instance -d arangodb -p 8529:8529Running the tests
Install and start Arangodb before running the tests.
arangod.conf
endpoint = tcp://127.0.0.1:8529
authentication = falsenpm run testInstall
npm i hemera-arango-store --saveUsage
const hemera = new Hemera(nats)
hemera.use(require('hemera-joi'))
hemera.use(require('hemera-arango-store'), {
database: {
url: 'http://127.0.0.1:8529',
name: 'test' // default database
}
})Plugin decorators
- hemera.arango
- hemera.aql
API
See Store Interface.
Database specific interface
createCollection
The pattern is:
topic: is the store name to publish toarango-storecmd: is the command to executecreateCollectionname: the name of the collectionstringdatabase: the database to use against the query.string(optional)type: the type of collection to createedgeor""(optional)
Example:
hemera.act(
{
topic: 'arango-store',
cmd: 'createCollection',
name: 'products'
},
function(err, resp) {}
)executeAqlQuery
The pattern is:
topic: is the store name to publish toarango-storecmd: is the command to executeexecuteAqlQuerydatabase: the database to use against the query.string(optional)query: the AQL querystringtype: return one or multiple resultsoneorall
Example:
hemera.act(
{
topic: 'arango-store',
cmd: 'executeAqlQuery',
type: 'one',
database: 'test',
query: aql`INSERT ${user} INTO testColl return NEW`
},
function(err, resp) {}
)executeTransaction
The pattern is:
topic: is the store name to publish toarango-storecmd: is the command to executeexecuteTransactiondatabase: the database to use against the query.string(optional)action: a string evaluating to a JavaScript function to be executed on the server.stringparams: available as variableparamswhen the action function is being executed on server. Check the example below.objectcollection: If collections is an array or string, it will be treated as collections.write.object(optional)read: an array of names (or a single name) of collections that will be read from during the transaction.Array<string>(optional)write: an array of names (or a single name) of collections that will be written from during the transaction.Array<string>(optional)
lockTimeout: determines how long the database will wait while attemping to gain locks on collections used by the transaction before timing out.integer
Example:
var action = String(function() {
return true
})
hemera.act(
{
topic: 'arango-store',
cmd: 'executeTransaction',
database: 'test',
action,
params: {
age: 12
},
collections: {
read: 'users'
}
},
function(err, resp) {}
)createDatabase
The pattern is:
topic: is the store name to publish toarango-storecmd: is the command to executeexecuteAqlQueryname: the name of the database.string
Example:
hemera.act(
{
topic: 'arango-store',
cmd: 'createDatabase',
name: 'test'
},
function(err, resp) {}
)8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago