How to use aggregation function mongo db-query

前端 未结 2 671
悲哀的现实
悲哀的现实 2021-01-27 07:19

I am new in MongoDB and I would like to use the aggregation function where I want to check type == topic and get the following output

E

2条回答
  •  囚心锁ツ
    2021-01-27 07:35

    To see the result of your aggregation you have to pass the callback to be executed as parameter.

    records.PedagogyVersions.aggregate([
            {
                $match:{_id:latestVersion} // Step 4
            },
            {
               $unwind:"$contentNodes.LearningNodes"
            },
            {
                $group:
                {
                    _id:"$contentNodes.LearningNodes",
                    count:{$sum:1}
                }
            }
        ], function(err, results) {
             console.log(results);
        });
    

提交回复
热议问题