mongodb - how to find and then aggregate

前端 未结 3 1371
忘了有多久
忘了有多久 2021-02-01 11:39

I have collection that contains documents with below schema. I want to filter/find all documents that contain the gender female and aggregate the sum of brainscore. I tried the

3条回答
  •  难免孤独
    2021-02-01 12:27

    Sample working query :

    db.getCollection('NOTIF_EVENT_RESULT').aggregate([
    {$match:
        {'userId': {'$in' : ['user-900', 'user-1546']},
        'criteria.operator': 'greater than', 'criteria.thresold' : '90', 'category' : 'capacity'}
    },
    {"$group" :  {_id : {userId:"$userId"}, "count" : { "$sum" : 1} } }
    ])
    

提交回复
热议问题