ArangoJS 4 Alpha: Available Now for Testing
The first alpha of the official JavaScript driver arangojs‘ upcoming major release is now available on npm.
Version 4 streamlines the driver’s API by removing unnecessary server roundtrips to obtain references to collections and graphs that already exist:
Before:
var db = require('arangojs')();
db.collection('users')
.then(function(collection) {
return collection.import(allTheUsers)
})
.then(function() {
return db.collection('blogs')
})
.then(function(collection) {
return collection.import(allTheBlogs);
})
.then(function() {
return db.collection('articles')
})
.then(function(collection) {
return collection.import(allTheArticles);
})
.then(handleSuccess)
.catch(handleErrors);
After:
var db = require('arangojs')();
db.collection('users').import(allTheUsers)
.then(function() {
return db.collection('blogs').import(allTheBlogs);
})
.then(function() {
return db.collection('articles').import(allTheArticles);
})
.then(handleSuccess)
.catch(handleErrors);
Additionally support has been added for more simple queries, e.g. byExample
:
db.collection('users').byExample({isAdmin: true})
.then(function (cursor) {
cursor.each(function (adminUser) {
doSomethingWith(adminUser);
});
});
And finally arangojs 4 will provide the aqlQuery
template string handler that will also be available in ArangoDB 2.7, to allow you to write AQL queries more easily in ES2015 environments or when using Babel:
var aqlQuery = require('arangojs').aqlQuery;
var collection = db.collection('users');
var value = true;
db.query(
aqlQuery`
FOR user IN ${collection}
FILTER isAdmin == ${value}
RETURN user
`
)
.then(doSomethingClever);
The arangojs 4 alpha is available on npm using the alpha
dist-tag:
npm install arangojs@alpha
Get the latest tutorials, blog posts and news: