TodoMVC Foxx application written for ArangoDB.A
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.
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.
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:
/todoGET: Invokes todos.list
/todoPOST: Invokes todos.save
/todo/:idPUT: Invokes todos.update
/todo/:idDELETE: Invokes todo.destroy
After installing ArangoDB, start your server and point it to the location of the cloned repository:
Then start your Arango shell (
$ arangosh) 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 Apache License.