SlideShare a Scribd company logo
by
Michael Hackstein
@mchacki
Rapid API Development
ArangoDB Foxx
Michael Hackstein
@mchacki
• Member of ArangoDB
Core Team
• web front-end
• graph features
• Organizer of cologne.js
• Master’s Degree

(spec. Databases and

Information Systems)
Classical
Web Applications
Application Logic
Single Page
Web Applications
Application Logic
The Idea
• What if we could talk to
the database directly?
• It would only need an API
• What if we could define
this API in JavaScript?
Single Page
Web Applications
This doesn‘t mean its a Rails/… Killer
Client Server DB
Client Server
(optional)
DB
with Foxx
What is ?
• a multi-model database (document store & graph database)
• is open source and free (Apache 2 license)
• offers convenient queries (via HTTP/REST and AQL)
• offers high performance and is memory efficient
• uses JavaScript throughout (V8 built into server)
• doubles as a web and application server (Foxx)
• offers many drivers for a wide range of languages
• is easy to use with web frontend and good documentation
• enjoys good professional as well as community support
• and recently added sharding in Version 2.0.
/
(~(
) ) /_/
( _-----_(@ @)
(  /
/|/--| V
" " " "
• … a feature of ArangoDB since 1.4
• … an easy way to define REST APIs on top of
ArangoDB
• … a toolset for developing your single page
web application
• … not requiring any special code on the client
side – use it with Angular, Backbone,
Ember,…
Foxx is…
Why another solution?
• ArangoDB Foxx is streamlined for API
creation – not a Jack of all trades
• There‘s no communication overhead
between (serverside) application and
database
• It is designed for front end developers: Use
JavaScript, you already know that
Foxx.Controller
Foxx = require("org/arangodb/foxx");
Foxx = require("org/arangodb/foxx");
controller = new Foxx.Controller(appContext);
Foxx = require("org/arangodb/foxx");
controller = new Foxx.Controller(appContext);
controller.get("/users", function(req, res) {
});
Foxx = require("org/arangodb/foxx");
controller = new Foxx.Controller(appContext);
controller.get("/users", function(req, res) {
res.json({
hello: "world"
});
});
Parameterize
the routes
• You may want a route like `users/:name`…
• …and then access the value of `name` easily
Foxx = require("org/arangodb/foxx");
!
controller = new Foxx.Controller(appContext);
!
controller.get("/users", function(req, res) {
res.json({
hello: "world"
});
});
Foxx = require("org/arangodb/foxx");
!
controller = new Foxx.Controller(appContext);
!
controller.get("/users ", function(req, res) {
res.json({
hello: "world"
});
});
/:name
Foxx = require("org/arangodb/foxx");
!
controller = new Foxx.Controller(appContext);
!
controller.get("/users ", function(req, res) {
res.json({
hello: "world"
});
});
req.params("name");
/:name
• In your Foxx.Controller you describe your
routes
• But your application can consist of multiple
Foxx.Controllers
• … and you also want to deliver assets and
files
Manifest.json
{
"name": "my_website",
"version": "1.2.1",
"description": "My Website with a blog and a shop",
"thumbnail": "images/website-logo.png",
!
"controllers": {
"/blog": "apps/blog.js",
"/shop": "apps/shop.js"
},
!
"assets": {
"application.js": {
"files": [
"vendor/jquery.js",
"assets/javascripts/*"
]
}
}
}
{
"name": "my_website",
"version": "1.2.1",
"description": "My Website with a blog and a shop",
"thumbnail": "images/website-logo.png",
!
"controllers": {
"/blog": "apps/blog.js",
"/shop": "apps/shop.js"
},
!
"assets": {
"application.js": {
"files": [
"vendor/jquery.js",
"assets/javascripts/*"
]
}
}
}
{
"name": "my_website",
"version": "1.2.1",
"description": "My Website with a blog and a shop",
"thumbnail": "images/website-logo.png",
!
"controllers": {
"/blog": "apps/blog.js",
"/shop": "apps/shop.js"
},
!
"assets": {
"application.js": {
"files": [
"vendor/jquery.js",
"assets/javascripts/*"
]
}
}
}
More
• Define a setup and teardown function to
create and delete collections
• Define lib to set a base path for your require
statements
• Define files to deliver binary data unaltered
Documentation
as a first class citizen
Annotate your Routes
• For Documentation
• But it is also used for validation
controller.get("/users/:name", function(req, res) {
res.json({
hello: req.params("name");
});
});
controller.get("/users/:name", function(req, res) {
res.json({
hello: req.params("name");
});
}).pathParam("name", {
description: "Name of the User",
dataType: "string"
});
;
controller.get("/users/:name", function(req, res) {
res.json({
hello: req.params("name");
});
}).pathParam("name", {
description: "Name of the User",
dataType: "string"
});
/** What's my name?
*
* This route knows it.
*/
Automatically generate
Swagger Docs
Foxx.Repository and
Foxx.Model
Domain Models Persistence
Foxx.Model Foxx.Repository
Foxx.Model Foxx.Repository
• Representation of the data
• Convenience Methods
• Validation
• Save and Retrieve Data
• Simple Queries
• Define your own queries
Why this separation?
• It doesn‘t violate the SRP like ActiveRecord
• In a lot of cases you can use the standard
Repository or Model and don‘t need your own
• It‘s great for testing
• You can mock the collection and the model
prototype to test your Repository
• You don‘t need to mock anything to test
your model
Foxx.Model
• The constructor takes a hash of attributes
• Access the attributes with get, set and has
• The forDB will be used to write the data into
the database
• Use forClient to prepare the data for delivery
Foxx.Repository
• The constructor takes an arangodb-
collection and the prototype of the model
• save for example expects an instance of the
model
• firstExample finds a suitable dataset and
returns it as an instance of the model
• Other methods: remove, replace, update…
You need more?
• Use Foxx.Repository.extend and
Foxx.Model.extend to inherit from the
prototype
• Add your own methods
• Your extensions live in separate files
Foxx = require("org/arangodb/foxx");!
!
MyRepository = Foxx.Repository.extend({
});!
!
exports.Repository = MyRepository;
byName: function (name) {!
return this.byExample({!
name: name!
});!
}
Foxx = require("org/arangodb/foxx");!
!
MyRepository = Foxx.Repository.extend({
});!
!
exports.Repository = MyRepository;
Thanks
• Please try ArangoDB Foxx
• www.arangodb.org
• We to get feedback
Contact
• I am mchacki everywhere:
• mchacki@arangodb.org
• @mchacki on Twitter
• mchacki on Github
Thanks
• First Slide version by Lucas Dohmen
• Database icon designed by Romeo Barreto
from The Noun Project
• Logos from Node.js, Ruby on Rails, Django,
AngularJS, Backbone, Ember and Symfony
from the respective projects
• All other icons are from Font Awesome

More Related Content

PDF
Experience with C++11 in ArangoDB
PDF
Rupy2012 ArangoDB Workshop Part2
PPT
Asp #2
PDF
Why we love ArangoDB. The hunt for the right NosQL Database
PPTX
Presentation: mongo db & elasticsearch & membase
PDF
Building a spa_in_30min
PPT
Ruby On Rails Siddhesh
Experience with C++11 in ArangoDB
Rupy2012 ArangoDB Workshop Part2
Asp #2
Why we love ArangoDB. The hunt for the right NosQL Database
Presentation: mongo db & elasticsearch & membase
Building a spa_in_30min
Ruby On Rails Siddhesh

What's hot (20)

PPT
PPTX
Introduction to ajax
PDF
DevOps in the era of serverless computing - Alessandro Vozza - Codemotion Ams...
PPTX
Introduction to ELK
PPT
Ajax Presentation
PPT
Ajax presentation
PPT
Ajax and PHP
PPT
Introduction to ajax
PPTX
Elastic - ELK, Logstash & Kibana
PPTX
ELK Elasticsearch Logstash and Kibana Stack for Log Management
PPTX
Introduction to ajax
PDF
Oracle APEX Nitro
PPT
Asynchronous JavaScript & XML (AJAX)
PPTX
Overview of AJAX
PPTX
What is Ajax technology?
PDF
ELK introduction
PDF
Presto at Facebook - Presto Meetup @ Boston (10/6/2015)
PPTX
Grokking TechTalk #24: Thiết kế hệ thống Background Job Queue bằng Ruby & Pos...
PPTX
ACTIVE SERVER PAGES BY SAIKIRAN PANJALA
Introduction to ajax
DevOps in the era of serverless computing - Alessandro Vozza - Codemotion Ams...
Introduction to ELK
Ajax Presentation
Ajax presentation
Ajax and PHP
Introduction to ajax
Elastic - ELK, Logstash & Kibana
ELK Elasticsearch Logstash and Kibana Stack for Log Management
Introduction to ajax
Oracle APEX Nitro
Asynchronous JavaScript & XML (AJAX)
Overview of AJAX
What is Ajax technology?
ELK introduction
Presto at Facebook - Presto Meetup @ Boston (10/6/2015)
Grokking TechTalk #24: Thiết kế hệ thống Background Job Queue bằng Ruby & Pos...
ACTIVE SERVER PAGES BY SAIKIRAN PANJALA
Ad

Similar to Rapid API Development ArangoDB Foxx (20)

PDF
Building APIs in an easy way using API Platform
PPTX
Introduction to Monsoon PHP framework
PDF
FOXX - a Javascript application framework on top of ArangoDB
PPTX
Ei cakephp
PPTX
Cakeph pppt
PDF
PLAT-7 Spring Web Scripts and Spring Surf
PDF
PLAT-7 Spring Web Scripts and Spring Surf
PPTX
Introduction to Laravel Framework (5.2)
PDF
Solr Recipes Workshop
PDF
Vorontsov, golovko ssrf attacks and sockets. smorgasbord of vulnerabilities
PDF
Developer’s intro to the alfresco platform
PDF
PLAT-8 Spring Web Scripts and Spring Surf
PDF
REST easy with API Platform
PDF
PHP, the GraphQL ecosystem and GraphQLite
KEY
QueryPath, Mash-ups, and Web Services
PDF
Apache Big Data EU 2016: Building Streaming Applications with Apache Apex
PDF
Ratpack Web Framework
PDF
Getting to know Laravel 5
PDF
Restful风格ž„web服务架构
PDF
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
 
Building APIs in an easy way using API Platform
Introduction to Monsoon PHP framework
FOXX - a Javascript application framework on top of ArangoDB
Ei cakephp
Cakeph pppt
PLAT-7 Spring Web Scripts and Spring Surf
PLAT-7 Spring Web Scripts and Spring Surf
Introduction to Laravel Framework (5.2)
Solr Recipes Workshop
Vorontsov, golovko ssrf attacks and sockets. smorgasbord of vulnerabilities
Developer’s intro to the alfresco platform
PLAT-8 Spring Web Scripts and Spring Surf
REST easy with API Platform
PHP, the GraphQL ecosystem and GraphQLite
QueryPath, Mash-ups, and Web Services
Apache Big Data EU 2016: Building Streaming Applications with Apache Apex
Ratpack Web Framework
Getting to know Laravel 5
Restful风格ž„web服务架构
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
 
Ad

Recently uploaded (20)

PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PPTX
Online Work Permit System for Fast Permit Processing
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
ai tools demonstartion for schools and inter college
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPT
Introduction Database Management System for Course Database
PDF
System and Network Administraation Chapter 3
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Navsoft: AI-Powered Business Solutions & Custom Software Development
Odoo Companies in India – Driving Business Transformation.pdf
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
Online Work Permit System for Fast Permit Processing
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Understanding Forklifts - TECH EHS Solution
Operating system designcfffgfgggggggvggggggggg
Softaken Excel to vCard Converter Software.pdf
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
ai tools demonstartion for schools and inter college
CHAPTER 2 - PM Management and IT Context
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Introduction Database Management System for Course Database
System and Network Administraation Chapter 3
Design an Analysis of Algorithms I-SECS-1021-03
Odoo POS Development Services by CandidRoot Solutions
Wondershare Filmora 15 Crack With Activation Key [2025

Rapid API Development ArangoDB Foxx