CouchApp - Build scalable web applications and relax


Published on

An introduction to CouchApp. Contains a brief intro to CouchDB than explains how to use CouchApp to maintain your design documents and how to create websites served by CouchDB.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

CouchApp - Build scalable web applications and relax

  1. 1. CouchApp Build scalable web applications and relax Wien, 7. April 2011 Gerhard Hipfinger
  2. 2. Before we begin First we need a brief intro to CouchDB
  3. 3. CouchDB is a schema free document store Access your documents via restful HTTP API JSON is used as document format What is CouchDB?
  4. 4. A simple example { "_id": "e3bcabbd12e92e4ea28198f5ad00756a", "_rev": "57-68386422f4554017aae948f0e5526425", "active": true, "email": "", "firstname": "Gerhard", "lastname": "Hipfinger", "dbName": "tempo_93aa6c3872ea46bb909365317c8dbfc3", "liveViewDayFolded": true, "liveViewWeekFolded": false, "liveViewMonthFolded": false, "creation": "2010-08-03T17:54:05.641+02:00", "docType": "TempoUser" }
  5. 5. How to access documents? Directly by URL and the document key Views (JavaScript Map/Reduce Scripts)
  6. 6. Map/Reduce sample function(doc) { if(doc.docType == 'TempoUser') { var date = doc.creation.substring(0,10); emit(date, 1); } } Map function Reduce function function(keys, values, rereduce) { return sum(values); }
  7. 7. What else can we do? Update functions for validation or authorization List functions for rendering lists Show functions for showing documents Binary attachments
  8. 8. So what? Finally you can save your app in CouchDB!
  9. 9. Now what's about CouchApp? CouchApp is a tool that helps you organize your CouchDB apps It's something like Ruby on Rails for CouchDB apps But it's not that easy and mature!
  10. 10. First steps with CouchApp Install CouchApp – it's a Python app Generate an application with couchapp generate You now have an ready to deploy CouchDB app
  11. 11. Maintain and Deploy You can use git, svn or whatever you want to manage your app couchapp push is used to deploy your app to a CouchDB node CouchApp finally helps you to maintain your design documents
  12. 12. CouchApp file mapping myapp/ views/ foobar/ map.js reduce.js { "_id" : "_design/myapp", "views" : { "foobar" : { "map" : "contents of map.js", "reduce" : "contents of reduce.js" } } }
  13. 13. CouchApp programming model CouchApp is much more than a code generator It also contains frontend libraries for fast UI development jQuery based Ajax „Evently“ and „Pathbinder“ JavaScript Frameworks for UI event handling
  14. 14. One solution for all apps? Relax in any case?
  15. 15. One solution for all apps? NO CouchApp is great to manage your design documents Don't manage your design documents (views, update functions) without CouchApp But be carefull when you try to create webapps only with CouchApp!
  16. 16. Good for... Small web apps that can be handled in a single page (like GWT) When your webapp does not require massive busines logic Bigger sites become hard to maintain Tool support only rudimentary
  17. 17. Questions?
  18. 18. Useful resources
  19. 19. Gerhard Hipfinger openForce Information Technology GesmbH Dresdner Str. 108 / 3. Stock / Top 11 1200 Wien TEL +43 1 3191775 FAX +43 1 3191775-20