【发布时间】:2022-02-10 11:54:11
【问题描述】:
我真的很困惑这里发生了什么:
当我使用以下代码时,我得到了预期的产品
const newProd = await models.Product.findOne({_id: new Buffer(util.HexUUIDToBase64(newProductData._id), 'base64').toString('hex')})
.populate({
path: 'SellerID',
populate: { path: 'UserID' }})
console.log(newProd)
但是,当我使用此代码时,我的产品一无所获:
const newProd = await models.Product.findOne({_id: new Buffer(util.HexUUIDToBase64(newProductData._id), 'base64').toString('hex')})
.populate({
path: 'SellerID',
populate: { path: 'UserID' }}).exec(function (err, product) {
console.log(err)
console.log(product)
})
console.log(newProd)
我希望我的产品能够传递给回调,但事实并非如此。这里到底发生了什么,我该如何解决?
【问题讨论】:
标签: javascript node.js database mongodb mongoose