在聚合查找中查找计数

时间:2016-03-14 04:49:37

标签: mongodb-query

我希望找出聚合加入的总文件数。如果有人有想法请告诉我。这是我的代码

        db.collection("camp", function (err, camp) {
        camp.aggregate([{$match: {status: {$ne: "Rejected"}}}, 
             {'$lookup': {

                    from: "organization",
                    localField: "organization",
                    foreignField: "organizationId",
                    as: "orgnData"
                }
            }, {'$lookup': {
                    from: "organizer",
                    localField: "organizer",
                    foreignField: "organizerId",
                    as: "ornrData"
                }},
            {$unwind: "$orgnData"},
            {$unwind: "$ornrData"},
            {$match: {'ornrData.city': 'Nagpur'}},

            {$skip: 0}, {$limit: 10}, 
            {$sort: {id: -1}}

        ], function (err, info) {
            res.json(info);
        });
    });

在上面的代码中,我希望在限制之前获得结果的总行数,以使用分页栏。如果有人有想法请告诉我?

0 个答案:

没有答案