ArangoDB’s Actions

    In some ways the communication layer of the ArangoDB server behaves like a Webserver. Unlike a Web server, it normally responds to HTTP requests by deliveringJSON objects. Remember, documents in the database are just JSON objects. So,most of the time the HTTP response will contain a JSON document from thedatabase as body. You can extract the documents stored in the database usingHTTP GET. You can store documents using HTTP POST.

    However, there is something more. You can write small snippets - so calledactions - to extend the database. The idea of actions is that sometimes it isbetter to store parts of the business logic within ArangoDB.

    Or, for instance, if you want to apply some statistics to large data-sets andyou cannot easily express this as query. You can define a action instead oftransferring the whole data to the client and do the computation on the client.

    Actions are also useful if you want to restrict and filter data according tosome complex permission system.

    In general you will use Foxx to easily extend the database withbusiness logic. Foxx provides an simple to use interface to actions.

    The following sections will explain the low-level actions within ArangoDB onwhich Foxx is built and show how to define them. The examples start withdelivering static HTML pages - even if this is not the primary use-case foractions. The later sections will then show you how to code some pieces of yourbusiness logic and return JSON objects.

    Note that unlike node.js, ArangoDB is multi-threaded and there is no easy way toshare state between queries inside the JavaScript engine. If such stateinformation is required, you need to use the database itself.