express-restify-mongoose icon indicating copy to clipboard operation
express-restify-mongoose copied to clipboard

On update, depopulated fields should be repopulated

Open Zertz opened this issue 8 years ago • 0 comments

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.

Zertz avatar Mar 28 '16 18:03 Zertz