ArangoDB Client for nodejs released
Estimated reading time: 1 minutes
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.

Leave a Comment