loopback-node-arangodb

0.1.0 • Public • Published

NPM

loopback-node-arangodb

This module is designed for the Strongloop Loopback framework. It adds _id attributes to any Model.

_id A document handle uniquely identifies a document in the database. It is a string and consists of the collection's name and the document key (_key attribute) separated by /.

INSTALL

  npm install --save loopback-node-arangodb

MIXINSOURCES

With loopback-boot@v2.8.0 mixinSources have been implemented in a way which allows for loading this mixin without changes to the server.js file previously required.

Add the mixins property to your server/model-config.json like the following:

{
  "_meta": {
    "sources": [
      "loopback/common/models",
      "loopback/server/models",
      "../common/models",
      "./models"
    ],
    "mixins": [
      "loopback/common/mixins",
      "../node_modules/loopback-node-arangodb/dist",
      "../common/mixins"
    ]
  }
}

CONFIG

To use with your Models add the mixins attribute to the definition object of your model config.

  {
    "name": "Friend",
    "properties": {
      "label": {
        "type": "string"
      }
    },
    "mixins": {
      "Node" : true
    }
  }

BOOT OPTIONS

The attribute name _id, is configurable. To use different values for the default attribute name add the following parameters to the mixin options.

In this example we change _id, to completeId respectively.

  {
    "name": "Friend",
    "properties": {
      "label": {
        "type": "string"
      }
    },
    "mixins": {
      "Node" : {
        "_id" : "completeId"
      }
    }
  }

TESTING

This package uses jscs and jshint as pretests to help maintain style and for error checking.

Run the tests in the test directory.

  npm test

Run with debugging output on:

  DEBUG='loopback:mixin:node-arangodb' npm test

LICENSE

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i loopback-node-arangodb

Weekly Downloads

0

Version

0.1.0

License

MIT

Last publish

Collaborators

  • mrbatista