Converting Mongoose documents to JSON and returning response
To convert documents to JSON and return a response with Express.js + Mongoose:
UserModel.find().lean().exec(function (err, users) {
return res.json(users)
});
You can use the lean() option to get plain javascript objects and return them with res.json.
That’s all from the Gemba.