我仍处于 Node.js 和 Moongoose 的学习阶段,我有一个场景
我的逻辑:
article.owner = User.findOne({ 'name' : 'ABC' })
.exec(function (err, user){
return user
})
Run Code Online (Sandbox Code Playgroud)
但它没有返回结果。我参考了其他一些答案并尝试过,async.parallel但我仍然无法在文章架构中保存 ABC 用户的 objectID,因为article.owner我总是为空。
请建议我任何其他更好的方法。