emme
Quickly and easily expose your Mongoose models to the world with an easy to customize API built on top of Express.
var express = mongoose = bodyParser = em = ; var UserModel = CommentModel = ; em var app = ;app; // expose user modelapp; // The following routes are now exposed// /user GET(browse), POST(create)// /user/:id GET(get), POST(save)
Documentation
Exposer
require(em-expose)(Model, options)
expose(Model, options) Builds an Express router that exposes the Mongoose model.
Arguments
Model
- a Mongoose modeloptions
private
- Object of paths that are not shown or editable.protected
- Object of paths that are shown but not editable.methods
- Object to override individual method settingsbrowse
,create
,retrieve
,update
, and/ordelete
private
- Override the object of paths that are not shown or editable.protected
- Override the object of paths that are shown but not editable. (only matters oncreate
andupdate
)preModel
-function(req, res, nex)
- Express style function, called before model is requestedpostModel
-function(req, res, next)
- Express style function, called after/if model has been found (access it withreq.doc
)preSend
-function(req, res, next)
- Express style function, called just before sending the model