在$ mongoose中使用$ unwind计算$ lookup $查询集合的大小...!

时间:2018-05-03 05:34:09

标签: mongoose

我的查询是......

aggregate[{
        $lookup: {
            "from": "replacement_articles",
            "localField": "_id",
            "foreignField": "userid",
            "as": "replacement_articles"
        }
    },
        {
            $unwind: "$replacement_articles"
        },
        {
            _id: "$id",
            article_count: { "$push": { "$size": "replacement_articles" } }
        }
    ]

MongoError:$ size的参数必须是数组,但类型为:missing

0 个答案:

没有答案