我的控制台上出现以下错误::* 无效的$project::原因:无法识别的$filter参数:限额 *
具有讽刺意味的是,documentation告诉我们它存在并且可以使用。
"这是我的准则"
const docWorker = await _worker.aggregate([
{
$project: {
credencial: {
$cond: {
if: {
$eq: [{ $size: "$identificacionObra" }, 0],
},
then: false,
else: {
$cond: {
if: {
$gte: [
{
$size: {
$filter: {
input: "$identificacionObra",
cond: {
$eq: ["$$credencial.estado", true],
},
as: "credencial",
limit: 1, <--------- the limit parameter does not work
},
},
},
1,
],
},
then: true,
else: false,
},
},
},
},
},
},
{ $match: _match },
{ $sort: _sort },
{
$facet: {
paginatedResults: [
{ $skip: req.query.page * req.query.limit - req.query.limit },
{ $limit: parseInt(req.query.limit) },
],
totalCount: [
{
$count: "count",
},
],
},
},
]);
请帮帮我,我做错了什么?
1条答案
按热度按时间4ioopgfo1#
检查MongoDb的版本,过滤器中的限制仅在6.0中可用
以下是5.0 https://www.mongodb.com/docs/v5.0/reference/operator/aggregation/filter/文档