在猫鼬6中execPopulate()
似乎被移除。由于这个原因,下面的代码返回错误。
const t = new MyModel(value)
return t.save().then(t => t.populate('my-path').execPopulate())
我想知道如何在猫鼬6或以后保存后填充。仅供参考,在填充之前应该使用新创建的和未填充的实例,所以我不想使用MyModel.populate()
。
解决方案非常简单。populate()
本身返回正确的承诺。
const t = new MyModel(value)
return t.save().then(t => t.populate('my-path'))
我被误认为没有填充相关对象,但我发现它可以工作。