Node.js mongodb中的$size,带条件

Node.js mongodb中的$size,带条件,node.js,mongodb,aggregation,Node.js,Mongodb,Aggregation,我使用聚合从两个集合中获取值,一个是文件夹,另一个是检查。我得到了所有的数据,但我得到的检查计数是0 我的代码: mongo.folder.aggregate([ { $lookup: { from: 'inspections', localField: '_id',

我使用聚合从两个集合中获取值,一个是文件夹,另一个是检查。我得到了所有的数据,但我得到的检查计数是0

我的代码:

mongo.folder.aggregate([
                {
                    $lookup:
                    {
                        from: 'inspections',
                        localField: '_id',
                        foreignField: 'projectID',
                        as: 'projectdata'
                    }        
                },
                { $match : {
                    $and: [ 
                         querydata
                    ]
               }
            },
                {
                    "$project": {
                        "folder_name" : "$folder_name",
                        "location_name": "$location_name", 
                        "architect_name" :"$architect_name",
                        "cover_img": "$cover_img",
                        "created_date" : "$created_date",
                        "parent_id":"$parent_id",
                        "share" : "$share",
                        "share_id":'$share_id',
                        "user_id": "$user_id",
                        "customer_id" : "$customer_id",
                        "download_access" :  "$download_access",
                        "inspection_count": {
                            "$size": {
                              "$filter": {
                                "input": "$projectdata.inspection_data",
                                "as": "el",
                                "cond": { "$eq": [ "$$el.published", "Y" ] }
                              }
                            }
                          }
                        }
                }
            ]).exec(function (err, response) {
                console.log("Inside Parent Id 1")

                console.log(response)

                        if(response){
                        response.splice(0, 0, responseparent);
                        }
                        else
                        {
                        response  = responseparent;
                        }
                if (err){ 


                     res.json({ 'folder': [], 'filelist': [] }); } else {

                        res.json({ 'folder': response, 'filelist': [] }); }
            });
这里的检查计数应该是3,但我得到的是零计数。如何根据数组的字段值查找数组的大小。 我使用过过滤器,尽管它的计数显示为0