mongoose-express-rest

Mongoose Express Rest is a plugin for express to expose mongoose finders as simple crud/rest operations. The basic idea being you should just define your model and your finders and the rest should be be available.

#Mongoose-Express-Rest Mongoose Express Rest is a plugin for express to expose mongoose finders as simple crud/rest operations. The basic idea being you should just define your model and your finders and the rest should be be available.

#Warning Things seem to be usable. Only tested with this schema, sure there are a lot of edge cases not handled.

    app.use('/rest', require('mongoose-express-rest').rest(mongoose));

###If you had a schema such as

var Comments = new Schema({
 title     : String
, body      : String
, date      : Date
});
 
var BlogPost = new Schema({
 author    : ObjectId
, title     : String
, body      : String
, buf       : Buffer
, date      : Date
, comments  : [Comments]
, meta      : {
   votes : Number
 , favs  : Number
}
});
 
var Post = mongoose.model('BlogPost', BlogPost);

you could then access it at listing.

http://localhost:3000/rest/blogpost/
http://localhost:3000/rest/blogpost/$id
http://localhost:3000/rest/blogpost/$id/comments
http://localhost:3000/rest/blogpost/$id/comments/$id
or 
http://localhost:3000/rest/blogpost/$id/comments/0

###Pagination Pagination is also supported via skip= and limit= query params.

http://localhost:3000/rest/blogpost/$id?skip=10&limit=10

###Population Mongoose populate is supported, but this will be changing shortly to allow for more fine grained controll over population. Currently you can do

http://localhost:3000/rest/blogpost/$id?skip=10&populate=comments,author

It handles get/put/post/delete

It should also be able to be used with Class finders. TBD