Hotcode 2013: Javascript in a database (Part 2)

1.902 Aufrufe

Veröffentlicht am

In this hotcode 2013 talk Lucas and Frank gave an overview over NoSQL and explained why it is a good idea to use Javascript also in the database environment.

Veröffentlicht in: Technologie
0 Kommentare
1 Gefällt mir
Statistik
Notizen
  • Als Erste(r) kommentieren

Keine Downloads
Aufrufe
Aufrufe insgesamt
1.902
Auf SlideShare
0
Aus Einbettungen
0
Anzahl an Einbettungen
550
Aktionen
Geteilt
0
Downloads
0
Kommentare
0
Gefällt mir
1
Einbettungen 0
Keine Einbettungen

Keine Notizen für die Folie

Hotcode 2013: Javascript in a database (Part 2)

  1. 1. RWTH Aachen, Computer Science Student on branch mastertriAGENS GmbH, Developermoonglum moonbeamlabsby Lucas DohmenCreating APIs for Single Page Web ApplicationsArangoDB FoxxSamstag, 1. Juni 13
  2. 2. Single PageWeb ApplicationsSamstag, 1. Juni 13
  3. 3. The Idea• What if we could talk tothe database directly?• It would only need an API• What if we could definethis API in JavaScript?Samstag, 1. Juni 13
  4. 4. Single PageWeb ApplicationsSamstag, 1. Juni 13
  5. 5. Single PageWeb ApplicationsThis doesn‘t mean its a Rails/… KillerSamstag, 1. Juni 13
  6. 6. What is ?• Free and Open Source…• … Document and Graph Store…• … with embedded JavaScript…• … and an amazing query languageSamstag, 1. Juni 13
  7. 7. Samstag, 1. Juni 13
  8. 8. /(~() ) /_/( _-----_(@ @)( //|/--| V" " " "Samstag, 1. Juni 13
  9. 9. • An easy way to define REST APIs on top ofArangoDB• Tools for developing your single page webapplicationSamstag, 1. Juni 13
  10. 10. Why another solution?• ArangoDB Foxx is streamlined for APIcreation – not a Jack of all trades• It is designed for front end developers: UseJavaScript, you already know that (withoutrunning into callback hell *cough* Node.js)Samstag, 1. Juni 13
  11. 11. Foxx.ApplicationSamstag, 1. Juni 13
  12. 12. Samstag, 1. Juni 13
  13. 13. FoxxApplication = require("org/arangodb/foxx").Application;Samstag, 1. Juni 13
  14. 14. FoxxApplication = require("org/arangodb/foxx").Application;Samstag, 1. Juni 13
  15. 15. FoxxApplication = require("org/arangodb/foxx").Application;app = new FoxxApplication();Samstag, 1. Juni 13
  16. 16. FoxxApplication = require("org/arangodb/foxx").Application;app = new FoxxApplication();Samstag, 1. Juni 13
  17. 17. FoxxApplication = require("org/arangodb/foxx").Application;app = new FoxxApplication();app.get("/users", function(req, res) {});Samstag, 1. Juni 13
  18. 18. FoxxApplication = require("org/arangodb/foxx").Application;app = new FoxxApplication();app.get("/users", function(req, res) {});Samstag, 1. Juni 13
  19. 19. FoxxApplication = require("org/arangodb/foxx").Application;app = new FoxxApplication();app.get("/users", function(req, res) {});res.set("Content-Type", "text/plain");Samstag, 1. Juni 13
  20. 20. FoxxApplication = require("org/arangodb/foxx").Application;app = new FoxxApplication();app.get("/users", function(req, res) {});res.set("Content-Type", "text/plain");Samstag, 1. Juni 13
  21. 21. FoxxApplication = require("org/arangodb/foxx").Application;app = new FoxxApplication();app.get("/users", function(req, res) {});res.set("Content-Type", "text/plain");res.body = "Worked!";Samstag, 1. Juni 13
  22. 22. FoxxApplication = require("org/arangodb/foxx").Application;app = new FoxxApplication();app.get("/users", function(req, res) {res.set("Content-Type", "text/plain");});res.body = "Worked!";Samstag, 1. Juni 13
  23. 23. FoxxApplication = require("org/arangodb/foxx").Application;app = new FoxxApplication();app.get("/users", function(req, res) {res.set("Content-Type", "text/plain");});app.start(applicationContext);res.body = "Worked!";Samstag, 1. Juni 13
  24. 24. Parameterizethe routes• You may want a route like `users/:id`…• …and then access the value of `id` easilySamstag, 1. Juni 13
  25. 25. FoxxApplication = require("org/arangodb/foxx").Application;app = new FoxxApplication();app.get("/users", function(req, res) {res.set("Content-Type", "text/plain");});app.start(applicationContext);res.body = "Worked!";Samstag, 1. Juni 13
  26. 26. FoxxApplication = require("org/arangodb/foxx").Application;app = new FoxxApplication();app.get("/users ", function(req, res) {res.set("Content-Type", "text/plain");});app.start(applicationContext);res.body = "Worked!";Samstag, 1. Juni 13
  27. 27. FoxxApplication = require("org/arangodb/foxx").Application;app = new FoxxApplication();app.get("/users/:id", function(req, res) {res.set("Content-Type", "text/plain");});app.start(applicationContext);res.body = "Worked!";Samstag, 1. Juni 13
  28. 28. FoxxApplication = require("org/arangodb/foxx").Application;app = new FoxxApplication();app.get("/users/:id", function(req, res) {res.set("Content-Type", "text/plain");});app.start(applicationContext);res.body = "Worked!";Samstag, 1. Juni 13
  29. 29. FoxxApplication = require("org/arangodb/foxx").Application;app = new FoxxApplication();app.get("/users/:id", function(req, res) {res.set("Content-Type", "text/plain");res.body = "Your User: " + req.params("id");});app.start(applicationContext);Samstag, 1. Juni 13
  30. 30. • In your Foxx.Application you describe yourroutes• But your application can consist of multipleFoxx.Applications• … and you also want to deliver assets andfilesManifest.jsonSamstag, 1. Juni 13
  31. 31. {"name": "my_website","version": "1.2.1","description": "My Website with a blog and a shop","thumbnail": "images/website-logo.png","apps": {"/blog": "apps/blog.js","/shop": "apps/shop.js"},"assets": {"application.js": {"files": ["vendor/jquery.js","assets/javascripts/*"]}}}Samstag, 1. Juni 13
  32. 32. {"name": "my_website","version": "1.2.1","description": "My Website with a blog and a shop","thumbnail": "images/website-logo.png","apps": {"/blog": "apps/blog.js","/shop": "apps/shop.js"},"assets": {"application.js": {"files": ["vendor/jquery.js","assets/javascripts/*"]}}}Samstag, 1. Juni 13
  33. 33. {"name": "my_website","version": "1.2.1","description": "My Website with a blog and a shop","thumbnail": "images/website-logo.png","apps": {"/blog": "apps/blog.js","/shop": "apps/shop.js"},"assets": {"application.js": {"files": ["vendor/jquery.js","assets/javascripts/*"]}}}Samstag, 1. Juni 13
  34. 34. More• Define a setup and teardown function tocreate and delete collections• Define lib to set a base path for your requirestatements• Define files to deliver binary data unalteredSamstag, 1. Juni 13
  35. 35. Documentationas a first class citizenSamstag, 1. Juni 13
  36. 36. Annotate your Routes• For Documentation• But will later also be used for validation etc.Samstag, 1. Juni 13
  37. 37. FoxxApplication = require("org/arangodb/foxx").Application;app = new FoxxApplication();app.get("/users/:id", function(req, res) {res.set("Content-Type", "text/plain");res.body = "Your Wiese: " + req.params("id");});app.start(applicationContext);Samstag, 1. Juni 13
  38. 38. app.get("/users/:id", function(req, res) {res.set("Content-Type", "text/plain");res.body = "Your Wiese: " + req.params("id");});Samstag, 1. Juni 13
  39. 39. app.get("/users/:id", function(req, res) {res.set("Content-Type", "text/plain");res.body = "Your User: " + req.params("id");});Samstag, 1. Juni 13
  40. 40. app.get("/users/:id", function(req, res) {res.set("Content-Type", "text/plain");res.body = "Your User: " + req.params("id");});}).pathParam("id", {description: "ID of the User",dataType: "int"Samstag, 1. Juni 13
  41. 41. Automatically generateSwagger DocsSamstag, 1. Juni 13
  42. 42. If you want tolearn about• … how we use the Repository Pattern• … how you can structure your Foxx AppSamstag, 1. Juni 13
  43. 43. Join us at ourworkshoptomorrow11:00DB StageSamstag, 1. Juni 13

×