The solution for me was to use execPopulate, like so
const t = new MyModel(value)
return t.save().then(t => t.populate('my-path').execPopulate())
Update
Mongoose 6.X and up: .execPopulate() is removed and .populate() is no longer chainable
The above code should be written like:
const t = new MyModel(value)
return t.save().then(t => t.populate('my-path')) // Returns a promise
If you don't want a promise:
return t.save().then(t => t.populate('my-path')).then(t => t)
Since it is no longer chainable, the new way to populate multiple fields is to use an array or an object:
return t.save().then(t => t.populate(['my-path1', 'my-path2'])).then(t => t)
Resources:
- Gets _id(s) used during population of the given
path - All of the ways to use population
- Read in-depth about each populate API