A TodoMVC Foxx application written for ArangoDB.
The goal of Foxx apps implemented in ArangoDB is to easily create simple REST interfaces. The included asset pipeline allows it to deliver complete single page applications (e.g. using Backbone.js) without a separate backend layer written in an arbitrary web framework. A Foxx app can be used to provide a basic application logic and a persistent data-storage in ArangoDB.
aye_aye is an introducing example for this. It consists of a simple frontend and backend component.
The backbone frontend is based on TodoMVC's Backbone.js example. (All credits to the authors.) It shows how the MV* pattern is applied in Backbone.js.
The original persistance layer (backbone-local-storage) has been replaced to use the REST-Interface defined in the aye_aye-foxx. This was easily archived by adding an url
function to all models and collections and removing the backbone-local-storage.
The backend is a Foxx application written for ArangoDB. It consists of five parts:
The manifest is a general description of the Foxx application, including name and version. Also it defines the location of all files, including the assets to build the frontend.
This script is executed whenever the aye_aye is mounted to a path. It creates the collection for our ToDos.
This script is executed whenever a the aye_aye is uninstalled from a path. It drops the collection of ToDos.
Define the models that are executed within the Arango.
The todos
model offers 4 functions:
- save: Store a new Todo.
- destroy: Remove the given Todo.
- list: Give a list of all Todos.
- update: Overwrite the given Todo.
Further libraries, but this feature is not used in the aye_aye.
The ayeaye.js
defines the REST interface.
At first it requires the todo
-model and creates a new Foxx.
Then it defines the offered REST functions:
/todo
GET: Invokes todos.list/todo
POST: Invokes todos.save/todo/:id
PUT: Invokes todos.update/todo/:id
DELETE: Invokes todo.destroy
After installing ArangoDB, start your server and point it to the location of the cloned repository:
$ ./bin/arangod --javascript.dev-app-path /path/to/aye_aye /path/to/your/arango_db
Then start your Arango shell ($ ./bin/arango
) and run the following commands:
arangosh> aal = require('org/arangodb/aal')
arangosh> aal.installDevApp('aye_aye', '/todo')
In this case, aye_aye gets mounted to '/todo' as main directory (but you can of cause adjust the path to your liking). Point your browser to http://localhost:8529/todo/
to run the application.
This code is distributed under the MIT license.