JavaScript Modules

ArangoDB uses a Node.js compatible module system. You can use the functionrequire() in order to load a module or library. It returns the exportedvariables 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:

  • assertimplements basic assertion and testing functions.

  • bufferimplements a binary data type for JavaScript.

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

  • eventsimplements an event emitter.

  • fsprovides a file system API for the manipulation of paths, directories, files,links, and the construction of file streams. ArangoDB implements mostFilesystem/Afunctions.

  • moduleprovides direct access to the module system.

  • pathimplements functions dealing with filenames and paths.

  • punycodeimplements conversion functions forpunycode encoding.

  • querystringprovides utilities for dealing with query strings.

  • streamprovides a streaming interface.

  • string_decoderimplements logic for decoding buffers into strings.

  • urlprovides utilities for URL resolution and parsing.

  • utilprovides 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 @arangodbnamespace, mostly for internal use by ArangoDB itself. The following modulesnoteworthy however and intended to be used by the user:

Bundled NPM Modules

The following NPM modulesare preinstalled:

  • aqbis the ArangoDB Query Builder and can be used to construct AQL querieswith a chaining JavaScript API.

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

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

  • error-stack-parserparses stacktraces into a more useful format.

  • graphql-syncis an ArangoDB-compatible GraphQL server/schema implementation.

  • highlight.jsis an HTML syntax highlighter.

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

  • iconv-liteis a utility library for converting between character encodings

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

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

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

  • minimatchis a glob matcher for matching wildcards in file paths.

  • qsprovides utilities for dealing with query strings using a different formatthan the querystring module.

  • semveris a utility library for handling semver version numbers.

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

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