express-restify-mongoose
express-restify-mongoose copied to clipboard
On update, depopulated fields should be repopulated
Currently,
PATCH /api/Model/id
{
populated: {
_id: 'some-id',
name: 'I am populated!'
}
}
Returns
{
populated: 'some-id'
}
The workaround I'm using:
postUpdate: function (req, res, next) {
req.erm.result.populate('populated').execPopulate().then((result) => {
req.erm.result = result
next()
}).catch(next)
}
Simple enough, but it would be super convenient if fields would automatically populate after being depopulated.