<commit_before># Hemera-arango-store package

This is a plugin to use [Arangodb](https://github.com/arangodb) with Hemera.

Execute any AQL query from anywhere. For more details [ArangoDB Query Language](https://www.arangodb.com/why-arangodb/sql-aql-comparison/)

### Start Arangodb with Docker

```js
docker run -e ARANGO_NO_AUTH=1 -d --name arangodb-instance -d arangodb -p 8529:8529
```

### Running the tests

Install and start Arangodb before starting.

**arangod.conf**
```
endpoint = tcp://127.0.0.1:8529
authentication = false
```

```
npm run test
```

#### Example

```js
'use strict'

const Hemera = require('nats-hemera')
const nats = require('nats').connect()
const hemeraArango = require('hemera-arango-store')
hemeraArango.options.arango = {
  url: 'http://127.0.0.1:8529',
  databaseName: 'test'
}

const hemera = new Hemera(nats, {
  logLevel: 'info'
})

hemera.use(hemeraArango)

hemera.ready(() => {

  let aql = hemera.exposition['hemera-arango-store'].aqlTemplate

  hemera.act({
    topic: 'arango-store',
    cmd: 'executeAqlQuery',
    type: 'all',
    query: `
    FOR u IN users
    RETURN u
`
  }, function (err, resp) {

    this.log.info(resp, 'Query result')
  })

  const user = {
    name: 'olaf'
  }

  hemera.act({
    topic: 'arango-store',
    cmd: 'executeAqlQuery',
    type: 'one',
    query: aql`INSERT ${user} INTO users`
  }, function (err, resp) {

    this.log.info(resp, 'Query result')
  })

})
```

## API

## Table of Contents

* [Collection API](#collection-api)
  * [topic:arango-store,cmd:createCollection](#create-collection)
* [Query API](#query-api)
  * [topic:arango-store,cmd:executeAqlQuery,type:all](#query-all)
  * [topic:arango-store,cmd:executeAqlQuery,type:one](#query-one)
* [Transaction API](#transaction-api)
  * [topic:arango-store,cmd:executeTransaction](#execute-transaction)
* [Database API](#database-api)
  * [topic:arango-store,cmd:createDatabase](#create-database)
  
#### query one

 Execute AQL Query and return the first result

**Arguments**

* **variables**: `object` (Default: `undefined`)

  The template variables for your AQL query.

* **databaseName**: `string` (Default: `""`)

  The database to use against the query.

* **query**: `string` (Default: `""`)
<commit_msg>update arango-store readme<commit_after># Hemera-arango-store package

This is a plugin to use [Arangodb](https://github.com/arangodb) with Hemera.

Execute any AQL query from anywhere. For more details [ArangoDB Query Language](https://www.arangodb.com/why-arangodb/sql-aql-comparison/)

### Start Arangodb with Docker

```js
docker run -e ARANGO_NO_AUTH=1 -d --name arangodb-instance -d arangodb -p 8529:8529
```

### Running the tests

Install and start Arangodb before starting.

**arangod.conf**
```
endpoint = tcp://127.0.0.1:8529
authentication = false
```

```
npm run test
```

#### Example

```js
'use strict'

const Hemera = require('nats-hemera')
const nats = require('nats').connect()
const hemeraArango = require('hemera-arango-store')
hemeraArango.options.arango = {
  url: 'http://127.0.0.1:8529',
  databaseName: 'test'
}

const hemera = new Hemera(nats, {
  logLevel: 'info'
})

hemera.use(hemeraArango)

hemera.ready(() => {

  let aql = hemera.exposition['hemera-arango-store'].aqlTemplate

  hemera.act({
    topic: 'arango-store',
    cmd: 'executeAqlQuery',
    type: 'all',
    query: `
    FOR u IN users
    RETURN u
`
  }, function (err, resp) {

    this.log.info(resp, 'Query result')
  })

  const user = {
    name: 'olaf'
  }

  hemera.act({
    topic: 'arango-store',
    cmd: 'executeAqlQuery',
    type: 'one',
    query: aql`INSERT ${user} INTO users`
  }, function (err, resp) {

    this.log.info(resp, 'Query result')
  })

})
```

## API

## Table of Contents

* [Store API](#Document-api)
  * [topic:arango-store,cmd:create](#create)
  * [topic:arango-store,cmd:update](#update)
  * [topic:arango-store,cmd:updateById](#updateById)
  * [topic:arango-store,cmd:find](#find)
  * [topic:arango-store,cmd:findById](#findById)
  * [topic:arango-store,cmd:remove](#remove)
  * [topic:arango-store,cmd:removeById](#removeById)
  * [topic:arango-store,cmd:replace](#replace)
  * [topic:arango-store,cmd:replaceById](#replaceById)

* [Driver API](#collection-api)
  * [Collection API](#collection-api)
    * [topic:arango-store,cmd:createCollection](#create-collection)
  * [Query API](#query-api)
    * [topic:arango-store,cmd:executeAqlQuery,type:all](#query-all)
    * [topic:arango-store,cmd:executeAqlQuery,type:one](#query-one)
  * [Transaction API](#transaction-api)
    * [topic:arango-store,cmd:executeTransaction](#execute-transaction)
  * [Database API](#database-api)
    * [topic:arango-store,cmd:createDatabase](#create-database)
  
#### query one

 Execute AQL Query and return the first result

**Arguments**

* **variables**: `object` (Default: `undefined`)

  The template variables for your AQL query.

* **databaseName**: `string` (Default: `""`)

  The database to use against the query.

* **query**: `string` (Default: `""`)

{'fraction_non_alphanumeric': 0.17302344060389352, 'fraction_numerical': 0.011521652761223678, 'mean_word_length': 4.379273504273504, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4369292', 'n_tokens_mistral': 1912, 'n_tokens_neox': 1774, 'n_words': 375}