Converting Mongoose documents to JSON and returning response

Tadashi Shigeoka ·  Thu, December 17, 2015

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.

Reference Information

That’s all from the Gemba.