0.3.5 • Published 12 years ago

mongoose-express-rest v0.3.5

Weekly downloads
17
License
-
Repository
github
Last release
12 years ago

#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.

Usage

    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

0.3.5

12 years ago

0.3.2

12 years ago

0.3.1

12 years ago

0.2.1

12 years ago

0.1.1

12 years ago