Giter Site home page Giter Site logo

arangojs's Introduction

ArangoDB JavaScript Driver

The official ArangoDB low-level JavaScript client.

license - APACHE-2.0 Dependencies

NPM status

Install

With Yarn or NPM

yarn add arangojs
## - or -
npm install --save arangojs

From source

git clone https://github.com/arangodb/arangojs.git
cd arangojs
npm install
npm run dist

Basic usage example

// Modern JavaScript
import { Database, aql } from "arangojs";
const db = new Database();
(async function() {
  const now = Date.now();
  try {
    const cursor = await db.query(aql`RETURN ${now}`);
    const result = await cursor.next();
    // ...
  } catch (err) {
    // ...
  }
})();

// or plain old Node-style
var arangojs = require("arangojs");
var db = new arangojs.Database();
var now = Date.now();
db.query({
  query: "RETURN @value",
  bindVars: { value: now }
})
  .then(function(cursor) {
    return cursor.next().then(function(result) {
      // ...
    });
  })
  .catch(function(err) {
    // ...
  });

Common issues

TypeScript error TS2304: Cannot find name 'Blob'.

Even if your project doesn't contain any browser code, you need to add "dom" to the "lib" array in your tsconfig.json to make arangojs work. This is a known limitation because the library supports both browser and Node environments and there is no common binary format that works in both environments:

// tsconfig.json
- "lib": ["es6"],
+ "lib": ["es6", "dom"],

Documentation

Latest Documentation

Testing

Run the tests using the yarn test or npm test commands:

yarn test
# - or -
npm test

By default the tests will be run against a server listening on http://localhost:8529 (using username root with no password). To override this, you can set the environment variable TEST_ARANGODB_URL to something different:

TEST_ARANGODB_URL=http://myserver.local:8530 yarn test
# - or -
TEST_ARANGODB_URL=http://myserver.local:8530 npm test

For development arangojs tracks the development build of ArangoDB. This means tests may reflect behavior that does not match any existing public release of ArangoDB.

To run tests for a specific release of ArangoDB other than the latest development build, use the environment variable ARANGO_VERSION, e.g. for 3.3:

ARANGO_VERSION=30300 yarn test
# - or -
ARANGO_VERSION=30300 npm test

The value follows the same format as the arangoVersion config option, i.e. XYYZZ where X is the major version, YY is the two digit minor version and ZZ is the two digit patch version (both zero filled to two digits).

Any incompatible tests will appear as skipped (not failed) in the test result.

To run the resilience/failover tests you need to set the environment variables RESILIENCE_ARANGO_BASEPATH (to use a local build of ArangoDB) or RESILIENCE_DOCKER_IMAGE (to use a docker image by name):

RESILIENCE_ARANGO_BASEPATH=../arangodb yarn test
# - or -
RESILIENCE_ARANGO_BASEPATH=../arangodb npm test

This runs only the resilience/failover tests, without running any other tests.

Note that these tests are generally a lot slower than the regular test suite because they involve shutting down and restarting individual ArangoDB server instances.

License

The Apache License, Version 2.0. For more information, see the accompanying LICENSE file.

arangojs's People

Contributors

andregs avatar ciscoheat avatar ctmakro avatar ctoesca avatar dontrelax avatar dothebart avatar f5io avatar fahrradflucht avatar fantoine avatar fceller avatar graetzer avatar greenkeeperio-bot avatar hgwood avatar hpurmann avatar hunter21007 avatar iyobo avatar janwo avatar jcambass avatar jdpnielsen avatar jsteemann avatar koba789 avatar lodestone avatar maxkernbach avatar neunhoef avatar oknoah avatar pekeler avatar petitchevalroux avatar pluma avatar simran-b avatar xescugc avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.