mongodb - MongoDB聚合数据
问题描述
当我从 Mongodb文档运行代码以在 $lookup 中使用管道时,
我收到一个错误,即let is not supported。如何在 $lookup 中使用 let: { <var_1>: , ..., <var_n>: }。
错误:
代码:
db.orders.aggregate([
{
$lookup:
{
from: "warehouses",
let: { order_item: "$item", order_qty: "$ordered" },
pipeline: [
{ $match:
{ $expr:
{ $and:
[
{ $eq: [ "$stock_item", "$$order_item" ] },
{ $gte: [ "$instock", "$$order_qty" ] }
]
}
}
},
{ $project: { stock_item: 0, _id: 0 } }
],
as: "stockdata"
}
}
])
解决方案
推荐阅读
- r - 如何在使用 tidymodels 时取消缩放和理解 glmnet 系数?
- mongodb - MongoDB Spring 聚合排除不起作用
- powershell - PowerShell Set-Partition -NewDriveLetter 返回 Set-Partition:请求的访问路径已在使用中。活动 ID {
- javascript - 二进制插入,数组的后半部分没有被递归调用?
- arrays - mongoose - 如何使用带有请求参数数组的 $in 进行 .find() 现在它只返回空数组
- javascript - 类型错误:fs.reddirSync 不是函数
- python - ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 2 is different from 1)
- java - MySQL 语句取消计时器未能停止
- asymptote - 重新缩放渐近线图片大小但将文本保持为一致大小
- oracle - 多个外键引用同一列