7.0.2 • Published 6 years ago

hemera-arango-store v7.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

:avocado: Hemera-arango-store package

Build Status npm styled with prettier

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:8529

Running the tests

Install and start Arangodb before running the tests.

arangod.conf

endpoint = tcp://127.0.0.1:8529
authentication = false
npm run test

Install

npm i hemera-arango-store --save

Usage

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 to arango-store
  • cmd: is the command to execute createCollection
  • name: the name of the collection string
  • database: the database to use against the query. string (optional)
  • type: the type of collection to create edge or "" (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 to arango-store
  • cmd: is the command to execute executeAqlQuery
  • database: the database to use against the query. string (optional)
  • query: the AQL query string
  • type: return one or multiple results one or all

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 to arango-store
  • cmd: is the command to execute executeTransaction
  • database: the database to use against the query. string (optional)
  • action: a string evaluating to a JavaScript function to be executed on the server. string
  • params: available as variable params when the action function is being executed on server. Check the example below. object
  • collection: 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 to arango-store
  • cmd: is the command to execute executeAqlQuery
  • name: the name of the database. string

Example:

hemera.act(
  {
    topic: 'arango-store',
    cmd: 'createDatabase',
    name: 'test'
  },
  function(err, resp) {}
)
7.0.2

6 years ago

7.0.1

6 years ago

7.0.0

6 years ago

6.0.1

6 years ago

6.0.0

6 years ago

5.0.0

6 years ago

4.0.2

6 years ago

4.0.1

6 years ago

4.0.0

6 years ago

3.0.2

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.1.35

7 years ago

1.1.34

7 years ago

1.1.33

7 years ago

1.1.32

7 years ago

1.1.31

7 years ago

1.1.30

7 years ago

1.1.29

7 years ago

1.1.28

7 years ago

1.1.27

7 years ago

1.1.26

7 years ago

1.1.25

7 years ago

1.1.24

7 years ago

1.1.23

7 years ago

1.1.22

7 years ago

1.1.21

7 years ago

1.1.20

7 years ago

1.1.19

7 years ago

1.1.18

7 years ago

1.1.17

7 years ago

1.1.16

7 years ago

1.1.15

7 years ago

1.1.14

7 years ago

1.1.13

7 years ago

1.1.12

7 years ago

1.1.11

7 years ago

1.1.10

7 years ago

1.1.9

7 years ago

1.1.8

7 years ago

1.1.7

7 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.27

7 years ago

1.0.26

7 years ago

1.0.25

7 years ago

1.0.24

7 years ago

1.0.23

7 years ago

1.0.22

7 years ago

1.0.21

7 years ago

1.0.20

7 years ago

1.0.19

7 years ago

1.0.18

7 years ago

1.0.17

7 years ago

1.0.16

7 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago