【发布时间】:2022-11-07 22:03:49
【问题描述】:
to Array 不是 mongodb 数据库、mongoose、node.js 中的函数
`getCartProducts: (userId) => {
return new Promise(async (resolve, reject) => {
let cart Items = await db.cart.aggregate([
{`your text`
$match: { user: user Id }//matched with the id
},
{
$lookup: {
from: "db.products",
let: { proList: '$products' },
pipeline: [
{
$match: {
$expr: {
$in: ["$_id", '$$proList']
}
}
}
],
as: 'cart Items' //converted as cart Items name
}
}
]).`to array`()
resolve(`cart Items`)
})
}
D b。大车。 aggregate().to 数组不是函数 我试图删除 to 数组,但它显示为未定义