arango-api

WARNING: This module is no longer maintained! Use `request-json`, `request-proxy` or one of the other arango clients instead.

npm install arango-api
13 downloads in the last week
20 downloads in the last month

WARNING: This module is no longer maintained!

Because ArangoDB currently only offers a REST API, a generic REST client like request-json can do most of the things this library set out to do.

If you find the pure REST API too inefficient, consider using ArangoDB's built-in view server Foxx to offload your logic into the database itself.

If you really want an ArangoDB-specific client library, try arango or one of the other ArangoDB drivers instead.

If you are interested in maintaining this library or want to claim the arango-api package on npm, feel free to report an issue on GitHub.

Synopsis

arango-api is a low-level REST API client for ArangoDB.

This project is currently very much work-in-progress, but aims to provide a thin wrapper around the standard REST API of ArangoDB that follows node API conventions very closely.

Build Status NPM version Dependencies

Install

Node.js

With NPM

npm install arango-api

From source

git clone https://github.com/pluma/arango-api.git
cd arango-api
npm install

API

All callbacks follow the standard node convention and receive an Error instance (if the action caused an error) and a result object. All functions that take a callback are asynchronous.

new Database([url:String]):db

Creates a new db object with the given connection string. Alternatively, a parsed URL object can be provided instead.

If no connection string is specified or the URL object is incomplete, the following defaults will be used:

  • hostname: 'localhost'
  • port: 8529
  • protocol: 'http'

db.collection

Provides access to the Collection REST API.

db.collection.create(data:Object, cb:Function)

Creates a collection with the given name and properties.

data.name:String (required)

Name of the new collection.

data.waitForSync:Boolean (Default: false)

Write the new collection to disk before finishing the operation.

data.journalSize:String (Default: see server configuration)

Maximal size of the journal file. Must be at least "1MB".

data.isSystem:Boolean (Default: false)

Marks the collection as a system collection. Reserved for internal use.

data.isVolatile:Boolean (Default: false)

The collection is stored in memory only and will never be written to disk. If the collection is unloaded, it will be discarded.

data.keyOptions:Object (optional)

Additional options for key generation.

keyOptions.type:String

The type of key generator. Legal values: "traditional" or "autoincrement".

keyOptions.allowUserKeys:Boolean

Whether keys for new documents can be defined by the client. Otherwise providing a key in new document data will result in an error.

keyOptions.increment:Number (if type is "autoincrement")

Increment value to be used when auto-incrementing keys.

keyOptions.offset:Number (if type is "autoincrement")

Offset value to be used when auto-incrementing keys.

data.options:Object (optional)

Additional collection options.

options.type:Number (Default: 2)

The collection type. Legal values: 2 (documents) or 3 (edges).

db.collection.get(name:String, cb:Function)

Fetches the metadata of the collection with the given name.

db.collection.properties(name:String, cb:Function)

Fetches the metadata of the collection with the given name, including its properties.

db.collection.properties(name:String, properties:Object, cb:Function)

Replaces the properties of the collection with the given name with the given data.

properties.waitForSync:Boolean (optional)

See db.collection.create.

properties.journalSize:String (optional)

See db.collection.create.

db.collection.count(name:String, cb:Function)

Fetches the metadata of the collection with the given name, including the number of documents in the collection.

db.collection.figures(name:String, cb:Function)

Fetches the metadata of the collection with the given name, including statistical information about the collection.

db.collection.revision(name:String, cb:Function)

Fetches the metadata of the collection with the given name, including its current revision.

db.collection.del(name:String, cb:Function)

Deletes the collection with the given name from the database.

db.collection.truncate(name:String, cb:Function)

Deletes all documents in the database with the given name.

db.collection.list([args:Object], cb:Function)

Lists the names and metadata of all collections in the database.

args.excludeSystem:Boolean (Default: false)

Whether to exclude system collections from the result.

db.collection.load(name:String, [args:Object], cb:Function)

Loads the collection with the given name into memory.

args.count:Boolean (Default: true)

Whether to include the document count for each collection.

db.collection.unload(name:String, cb:Function)

Removes the collection with the given name from memory.

db.collection.rename(name:String, newName:String, cb:Function)

Renames the collection with the given name to the given new name.

db.document

Provides access to the Document REST API.

db.document.create(data:Object, args:Object, cb:Function)

Creates a new document with the given data.

args.collection:String

Name of the collection to create the document in.

args.createCollection:Boolean (Default: false)

Whether to create the collection if it does not exist.

db.document.get(handle:String, [headers:Object], cb:Function)

Fetches the document with the given handle from the database.

headers.if-match:String (optional)

The operation will fail unless the document's current revision matches the given value.

headers.if-not-match:String (optional)

The operation will fail if the document's current revision matches the given value.

db.document.replace(data:Object, [args:Object], cb:Function)

Replaces the current revision of the given document with its data.

args.rev:String (optional)

The operation will fail unless the document's current revision matches the given value.

args.waitForSync:Boolean (Default: collection setting)

See db.collection.create.

args.policy:String (Default: "error")

Determines how to handle revision conflicts. Legal values: "error" (default) or "last" (forces replacements).

db.document.update(data:Object, [args:Object], cb:Function)

Updates the current revision of the given document with its data.

args.rev:String (optional)

The operation will fail unless the document's current revision matches the given value.

args.keepNull:Boolean (Default: true)

Document attributes set to null will be handled as regular values. Otherwise these attributes will be removed from the stored document instead.

args.waitForSync:Boolean (Default: collection setting)

See db.collection.create.

db.document.del(handle:String, [args:Object], cb:Function)

Deletes the document with the given handle permanently.

args.rev:String (optional)

The operation will fail unless the document's current revision matches the given value.

args.waitForSync:Boolean (Default: collection setting)

See db.collection.create.

db.document.list(args:Object, cb:Function)

Lists the handles of all documents in the given collection.

args.collection:String

Name of the collection the documents will be listed of.

db.edge

Provides access to the Edge API.

db.edge.create(data:Object, args:Object, cb:Function)

Creates a new edge document with the given data.

args.collection:String

The name of the collection in which to create the new edge document.

args.from:String

The handle of the document to use as the starting vertex.

args.to:String

The handle of the document to use as the ending vertex.

db.edge.get(handle:String, [headers:Object], cb:Function)

See db.document.get.

db.edge.replace(data:Object, [args:Object], cb:Function)

See db.document.replace.

db.edge.del(handle:String, [args:Object], cb:Function)

See db.document.del.

db.edge.list(name:String, args:Object, cb:Function)

Lists the edge documents matching the arguments in the collection with the given name.

args.vertex:String

Handle of the vertex to list the edges of.

args.direction:String

Direction of edges to list. Legal values: "any", "in", "out".

Unlicense

This is free and unencumbered public domain software. For more information, see http://unlicense.org/ or the accompanying UNLICENSE file.

npm loves you