DEV Community


Posted on • Updated on

ArangoDB : The new Graal ? Part 1

ArangoDB : The new Graal ? Part 1

I discovered ArangoDB 2 years ago ... I was looking for something new, something fresh. I was bored about deploying new application for any new project. Then I found ArangoDB ... And I still wonder why few people know it !

ArangoDB is a multi-model database (key/value; documents; graph) with transactions and joins.

ArangoDB provide Foxx, a micro service engine embedded in ArangoDB. Last but not least, Foxx services scales with database cluster. It's very powerful and can cover your needs for almost all your projects.

To be honest I use ArangoDB in single instance mode for now.

How does a service looks like ?

'use strict';
const db = require('@arangodb').db;
const createRouter = require('@arangodb/foxx/router');
const router = createRouter();


router.get('/', function(req, res) {
    res.send({ hello: 'world' });
Enter fullscreen mode Exit fullscreen mode

Easy, isn't it ? You can create any Rest verb you want (e.g. router.get,, router.put, router.delete, router.patch)

Ok that's cool ... but how to interact with the database, the collections, the graphs ?

ArangoDB provide a language request called AQL which will allow you to run requests in database just like SQL.

Let say we have created a collection called posts

Here an endpoint to load all posts filtered by a specific status and also return joined user.

router.get('/posts/:status', function(req, res) {
    const documents = db._query(`
        FOR post IN posts
            FILTER posts.status == @status
            FOR user IN users
                FILTER posts.user_key == user._key
                RETURN { post: post, user: user }
    `, { status: req.pathParams.status });

Enter fullscreen mode Exit fullscreen mode

ArangoDB UI will provide you a nice swagger documentation such as :

The biggest benefit to run Foxx is that it is hosted in the heart of the database and requests are blazing fasts.

On Part 2 I'll show you how to secure your APIs with a Json Web Token

For people working on OSX I wrote foxx-framework to simplify my daily workflow.

Top comments (1)

hrmny profile image

I was looking for a new db to try, may as well go for this one