home shape

ArangoDB Client for nodejs released

Note: Our new official nodejs driver is arangojs. You also can look at this blogpost about the new driver.

We got a note from Anders Elo from Sweden. He told us that he has released a ArangoDB client for node.js. Awesome! :-) You can find it on Github under the URL https://github.com/kaerus/arango-client. To install locally

npm install git://github.com/kaerus/arango-client

Anders also writes:

  • It's still lacking features and is prone to changes but it works quite nice, atleast I think so. :) I've not documented this project as of yet due to lack of time so I'll briefly instruct you by some examples.*
var arango = require('arango.client'), util = require('util');

/* Prepare a connection, defaults {protocol:'http', hostname:'127.0.0.1', port: 8529} */ 
db = new arango.Connection({name:"testcollection"});

/* we need to first create our test collection */
db.collection.create(function(err,ret){
  console.log("err(%s): ",err, ret);
});

/* create a new document in collection */
db.document.create({a:"test"},function(err,ret){
  if(err) console.log("error(%s): ", err,ret);
  else console.log(util.inspect(ret));
});

/* create a document and a new collection on demand */
db.document.create(true,"newcollection",{a:"test"},function(err,ret){
  if(err) console.log("error(%s): ", err,ret);
  else console.log(util.inspect(ret));
});

/* alternate style utilizing events */
db.document.list().on('result',function(result){
  console.log(util.inspect(result));
}).on('error',function(error){
  console.log("error(%s):", error.code, error.message);
});

The interface to the ArangoDB REST api resides in the lib/api directory. You can find out more details there. Anders also includes some tests, just runt "npm test" to execute them.

Frank Celler

Frank Celler

Frank is both entrepreneur and backend developer, developing mostly memory databases for two decades. He is the CTO and co-founder of ArangoDB. Try to challenge Frank asking him questions on C, C++ and MRuby. Besides Frank organizes Cologne’s NoSQL group & is an active member of NoSQL community.

10 Comments

  1. Shekar Tippur on May 26, 2013 at 7:48 am

    I am trying to include this on a intellij project. I get this error.

    db.document.create_(“newcollection”,{a:”test”},function(err,ret){

    ^

    TypeError: Object # has no method ‘create_’

    at Object. (/Users/shekart/WebstormProjects/byeh_new/arango_conn.js:26:13)

    at Module._compile (module.js:456:26)

    at Object.Module._extensions..js (module.js:474:10)

    at Module.load (module.js:356:32)

    at Function.Module._load (module.js:312:12)

    at Function.Module.runMain (module.js:497:10)

    at startup (node.js:119:16)

    at node.js:901:3

    Process finished with exit code 8

    If I change the _create to create, I get the below message
    error(404): collection /_api/collection/newcollection not found

    I am kinda new to all this. Really appreciate any pointers.

    – Shekar



    • luebbert42 on May 27, 2013 at 1:07 pm

      The api for “on demand collections” has changed, I have updated the example. Hint: Anders includes many examples in the test directory of the module 🙂



      • Shekar Tippur on May 28, 2013 at 8:58 am

        I have installed the latest node module.

        Here is the version info

        “name”: “arango.client”,

        “version”: “0.6.2”,

        I looked at the test folder ..
        https://github.com/kaerus-component/arango/blob/master/test/arango.js

        I see the below definition…

        var libs = [

        ‘../lib/arango’,

        ‘./lib/qunit-1.10.js’

        ];

        I dont see a relative folder ../lib/arango.

        And when I try to run this .. I get

        $ node arango.js

        /Users/shekart/WebstormProjects/byeh_new/node_modules/arango.client/test/arango.js:11

        module = QUnit.module;

        ^

        ReferenceError: QUnit is not defined

        I am sorry if I am posting trivial questions but I really appreciate any help.

        – Shekar



        • luebbert42 on May 28, 2013 at 9:53 am

          to run the tests on a fresh node installation in the current version of arango.client I had to install two additional modules, qunit and amdefine via

          sudo npm install amdefine
          sudo npm install qunit



          • Shekar Tippur on May 29, 2013 at 8:45 am

            Here is what I see on node_modules folder ..

            $ pwd

            /Users/shekart/WebstormProjects/byeh_new/node_modules

            $ ls

            amdefine arango.client express jade qunit

            I have installed both qunit and amdefine.

            I still see the same error.

            – Shekar



          • luebbert42 on May 29, 2013 at 10:39 am

            I wrote something in the Google Group (this is a bit more comfortable than the comment’s section :-))



          • Shekar Tippur on May 29, 2013 at 5:47 pm

            Disqus –

            I think I got over some hiccups :).

            I believe we need var QUnit = require(‘qunit’);

            I now have new set of error:

            /usr/local/bin/node collection.js
            /Users/shekart/WebstormProjects/byeh_new/node_modules/arango.client/test/api/collection.js:19 asyncTest(‘create’,2,function(){
            ^
            ReferenceError: asyncTest is not defined
            at Object. (/Users/shekart/WebstormProjects/byeh_new/node_modules/arango.client/test/api/collection.js:19:1) at runFactory (/Users/shekart/WebstormProjects/byeh_new/node_modules/arango.client/node_modules/amdefine/amdefine.js:181:30) at define (/Users/shekart/WebstormProjects/byeh_new/node_modules/arango.client/node_modules/amdefine/amdefine.js:275:13) at Object. (/Users/shekart/WebstormProjects/byeh_new/node_modules/arango.client/test/api/collection.js:10:1) at Module._compile (module.js:456:26)
            at Object.Module._extensions..js (module.js:474:10)
            at Module.load (module.js:356:32)
            at Function.Module._load (module.js:312:12)
            at Function.Module.runMain (module.js:497:10)
            at startup (node.js:119:16)

            Process finished with exit code 8

            I tried to precede it with function asyncTest(..

            I then get a different error ..

            /Users/shekart/WebstormProjects/byeh_new/node_modules/arango.client/test/api/collection.js:19 function asyncTest(‘create’,2,function(){
            ^^^^^^^^
            SyntaxError: Unexpected string
            at Module._compile (module.js:439:25)
            at Object.Module._extensions..js (module.js:474:10)
            at Module.load (module.js:356:32)
            at Function.Module._load (module.js:312:12)
            at Function.Module.runMain (module.js:497:10)
            at startup (node.js:119:16)
            at node.js:901:3

            Any idea on whats going on?

            – Shekar



          • Loremsqlsum on May 29, 2013 at 9:01 pm

            The blog is not a suitable place for Support. Please come to Google Groups.



  2. Shekar Tippur on May 28, 2013 at 5:45 pm

    I have installed both qunit and amdefine.

    I still see the same error.

    – Shekar



  3. Shekar Tippur on May 28, 2013 at 5:48 pm

    Here is what I see on node_modules folder ..

    $ pwd

    /Users/shekart/WebstormProjects/byeh_new/node_modules

    $ ls

    amdefine arango.client express jade qunit



Get the latest tutorials, blog posts and news: