Use colibri if you need to create RESTful backend to you mongodb collections in quick and easy way.
Let's write a backend for well-known ToDo application (see example/todo)
express=require'express'mongoose=require'mongoose'colibri=require'colibri'app=express.createServer()
app.useexpress.bodyParser()
app.useexpress.static"#{__dirname}/static"#mongoose-related stuff: Schema and Modelmongoose.connect'mongodb://localhost/colibriTodo'TodoSchema=newmongoose.Schematitle:Stringorder:Numberdone:type:Boolean, default:noTodoModel=mongoose.model'todo', TodoSchema
#And now - the magic!# - create REST backendresource=colibri.createResourcemodel: TodoModel
plainOutput:yes# - bind our rest backend to appresource.express app
#Listenapp.listen3000colibri adds the following routes automatically to your Express app:
GET /todo- get a list of itemsPOST /todo- create new itemGET /todo/:id- get an item with corresponding _idPUT /todo/:id- save an item with corresponding _idDELETE /todo/:id- delete an item with corresponding _id
We have a todo-server ready to use with - for example - Backbone.
