ArangoDB v3.8 reached End of Life (EOL) and is no longer supported.

This documentation is outdated. Please see the most recent version at docs.arangodb.com

JavaScript Modules

ArangoDB uses a Node.js compatible module system. You can use the function require() in order to load a module or library. It returns the exported variables and functions of the module.

The following global variables are available throughout ArangoDB and Foxx:

  • global
  • process
  • console
  • Buffer
  • __filename
  • __dirname

Node compatibility modules

ArangoDB supports a number of modules for compatibility with Node.js, including:

  • assert implements basic assertion and testing functions.

  • buffer implements a binary data type for JavaScript.

  • console is a well known logging facility to all the JavaScript developers. ArangoDB implements most of the Console API, with the exceptions of profile and count.

  • events implements an event emitter.

  • fs provides a file system API for the manipulation of paths, directories, files, links, and the construction of file streams. ArangoDB implements most Filesystem/A functions.

  • module provides direct access to the module system.

  • path implements functions dealing with filenames and paths.

  • punycode implements conversion functions for punycode encoding.

  • querystring provides utilities for dealing with query strings.

  • stream provides a streaming interface.

  • string_decoder implements logic for decoding buffers into strings.

  • url provides utilities for URL resolution and parsing.

  • util provides general utility functions like format and inspect.

Additionally ArangoDB provides partial implementations for the following modules:

  • net: only isIP, isIPv4 and isIPv6.

  • process: only env and cwd; stubs for argv, stdout.isTTY, stdout.write, nextTick.

  • timers: stubs for setImmediate, setTimeout, setInterval, clearImmediate, clearTimeout, clearInterval and ref.

  • tty: only isatty (always returns false).

  • vm: only runInThisContext.

The following Node.js modules are not available at all:

  • child_process
  • cluster
  • constants
  • crypto (but see @arangodb/crypto below)
  • dgram
  • dns
  • domain
  • http (but see @arangodb/request below)
  • https
  • os
  • sys
  • tls
  • v8
  • zlib

ArangoDB Specific Modules

There are a large number of ArangoDB-specific modules using the @arangodb namespace, mostly for internal use by ArangoDB itself. The following modules noteworthy however and intended to be used by the user:

Bundled NPM Modules

The following NPM modules are preinstalled:

  • aqb is the ArangoDB Query Builder and can be used to construct AQL queries with a chaining JavaScript API.

  • chai is a full-featured assertion library for writing JavaScript tests.

  • dedent is a simple utility function for formatting multi-line strings.

  • error-stack-parser parses stacktraces into a more useful format.

  • graphql-sync is a thin wrapper for old versions of graphql, allowing it to run in ArangoDB. This GraphQL server/schema implementation is deprecated and only shipped for backward compatibility. Version 0.12 and newer of the official graphql package can be used directly. New projects should bundle their own copy of this module: https://www.npmjs.com/package/graphql

  • highlight.js is an HTML syntax highlighter.

  • i (inflect) is a utility library for inflecting (e.g. pluralizing) words.

  • iconv-lite is a utility library for converting between character encodings

  • joi is a validation library that is supported throughout the Foxx framework.

  • js-yaml is a JavaScript implementation of the YAML data format (a partial superset of JSON).

  • lodash is a utility belt for JavaScript providing various useful helper functions.

  • minimatch is a glob matcher for matching wildcards in file paths.

  • qs provides utilities for dealing with query strings using a different format than the querystring module.

  • semver is a utility library for handling semver version numbers.

  • sinon is a mocking library for writing test stubs, mocks and spies.

  • timezone is a library for converting date time values between formats and timezones.