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 global variables global
, process
, console
, Buffer
, filename
and dirname
are available throughout ArangoDB and Foxx.
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 implementsconversion 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
andinspect
.
Additionally ArangoDB provides partial implementations for the following modules:
net
:onlyisIP
,isIPv4
andisIPv6
.process
:onlyenv
andcwd
;stubs forargv
,stdout.isTTY
,stdout.write
,nextTick
.timers
:stubs forsetImmediate
,setTimeout
,setInterval
,clearImmediate
,clearTimeout
,clearInterval
andref
.tty
:onlyisatty
(always returnsfalse
).vm
:onlyrunInThisContext
.
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 however are noteworthy:
@arangodb provides direct access to the database and its collections.
@arangodb/crypto provides various cryptography functions including hashing algorithms.
@arangodb/request provides the functionality for making synchronous HTTP/HTTPS requests.
@arangodb/foxx is the namespace providing the various building blocks of the Foxx microservice framework.
Bundled NPM Modules
The following NPM modules are preinstalled:
aqbis the ArangoDB Query Builder and can be used to construct AQL queries with 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 format than 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.