我是 mongoDB 的新手,我需要在 mongoDB 中将 $exists 与 $expr 一起使用,我尝试了以下操作:
$lookup: {
as: "collectionDet",
from: "collection",
let: { userId: "$userId" },
pipeline: [{
$match: {
$expr: {
$and: [
{ $eq: ["$_id", "$$userId"]},
{ $eq: ["$status", true], },
{
$or: [
{ $eq: ["$isDeleted", false ], },
{ $exists: ["$isDeleted", false ] },
],
}
],
},
},
}],
}
这是返回错误,例如:
"message": "无法识别的表达式 '$exists'"
有没有办法在 $expr 中使用 $exists 或任何其他可用的替代方案?