luin / express-promise

❤️ Middleware for easy rendering of async Query results.
MIT License
316 stars 19 forks source link

Can I use directly Mongoose Queries without constructing a top level object? #10

Closed pgrm closed 9 years ago

pgrm commented 9 years ago

Hi, great plugin, makes my code much easier to deal with :)

I'm currently building a REST API with a lot of mongoose and would like to have simple statements like:

res.json(User.find(req.params.userId));

does that work? I've seen in your code that you check the body object for being a promise, but not for being a mongoose query. I think, when creating REST interfaces often times you just want to pass on some data from DB without repackaging it into a different object, so returning it directly would help a lot.

Thanks

luin commented 9 years ago

I'll update this module today to let it support mongoose query.

pgrm commented 9 years ago

Thanks, it was actually quite easy to fix, I've sent you a PR - if you think, that the solution is ok. It works for me for now