Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

37 lines (28 sloc) 0.843 kb
mongo = require './mongo_driver'
ObjectID = mongo.ObjectID
db = null
mongo.db 'foo', 'users', (collections) ->
db = collections
exports.configure = (r) ->
r.get '/home', ->
this.render 'home'
r.get '/users/new', ->
this.render 'new'
r.post '/users', ->
that = this
db.users.insert this.params
db.users.find().toArray (err, items) ->
that.render 'users', users: items
r.get '/users/$', (id) ->
that = this
db.users.findOne _id: new ObjectID(id), (err, item) ->
that.render 'show', user: item
r.get '/users', ->
that = this
db.users.find().toArray (err, items) ->
that.render 'users', users: items
r.delete '/users/$', (id) ->
that = this
db.users.remove _id: new ObjectID(id)
db.users.find().toArray (err, items) ->
that.render 'users', users: items
Jump to Line
Something went wrong with that request. Please try again.