Socket
Socket
Sign inDemoInstall

arango-tools

Package Overview
Dependencies
1
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    arango-tools

tools for working with ArangoDB


Version published
Weekly downloads
75
increased by97.37%
Maintainers
1
Install size
4.16 MB
Created
Weekly downloads
 

Readme

Source

ArangoTools

ArangoJS describes itself as "The official ArangoDB low-level JavaScript client". The "low-level" part never really meant much to me in my inital usage. Over time I've been finding patterns in my own usage and accumulated workarounds, which I kept telling myself I would extract into a library. This is that library.

Installation

npm install arango-tools

Usage

The migrate call takes a set of json documents describing the desired state of the database, and returns a set of functions that allow you act on the objects you just created. Migrations are idempotent, and create resources only when the don't exist.

const { ArangoTools, dbNameFromFile } = require('arango-tools')
let name = dbNameFromFile(__filename)

let { migrate } = await ArangoTools({ rootPass, url })

let {query, truncate, drop, collections} = await migrate([
	{
		type: 'database',
		databaseName: name,
		users: [{ username: 'mike', passwd: 'sekret' }],
	},
	{
		type: 'documentcollection',
		databaseName: name,
		name: 'widgets',
		options: { journalsize: 10485760, waitforsync: true },
	},
	{
		type: 'geoindex',
		databaseName: name,
		collection: 'places',
		fields: ['pts'],
		geojson: true,
	},
])

await collections.widgets.save({foo: "bar"})

let cursor = await query`
FOR widget IN widgets
  FILTER widget.foo === "bar"
  RETURN widget
`

await cursor.all()
// [{foo: "bar"}]

await drop()

Issues

It's early!

The current implementation is basic but works. Currently the only migrations that work are creating a database, a document collection and a GeoIndex. Other types of indexes as well as graphs and edge collections will be added soon.

FAQs

Last updated on 28 May 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc