Skip to content

Commit

Permalink
+ couchapp design document
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanley committed Jan 12, 2012
1 parent 188f1b3 commit 86ee820
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
var couchapp = require('couchapp')
, path = require('path')

ddoc = {
_id: '_design/app',
views: {},
shows: {},
lists: {}
}

module.exports = ddoc

// GET /cafe/_design/app/_design/by_city
ddoc.views.by_city = {
map: function(doc){
emit([doc.city], doc)
}
}

// GET /cafe/_design/app/_show/cafe/<id>
ddoc.shows.cafe = function(doc,req){
return {
headers: {'Content-type': 'text/html'},
body: '<h1>'+ doc.name +'</h1>'
}
}

// GET /cafe/_design/app/_list/cafes/by_city
ddoc.lists.cafes = function(head,req){
while (cafe = getRow()){
send('<li>'+ cafe.value.name +'</li>')
}
}

couchapp.loadAttachments(ddoc, path.join(__dirname, '_attachments'))

0 comments on commit 86ee820

Please sign in to comment.