Database

[/** 1*/{"_id":1,"data_id":1,"data_test":"sample1","data_list":["sun"],},/** 2*/{"_id":2,"data_id":1,"data_test":"sample2","data_list":["sun","mon"],},/** 3*/{"_id":3,"data_id":2,"data_test":"sample3","data_list":["tue"],},/** 4*/{"_id":4,"data_id":2,"data_test":"sample4","data_list":["tue","wed"],}]

Query

db.collection.aggregate([/**{ $match: { "data_id": 1 } }, // If you want to aggregate for a single data_id*/{$unwind:"$data_list"},{$group:{_id:{data_id:"$data_id",/** If you want to aggregate for all data_ids*/data_list:"$data_list",},count:{$count:{}}}},{$group:{_id:"$_id.data_id",/** If you want to aggregate for all data_ids*_id: null,*/days:{$push:{k:"$_id.data_list",v:"$count"}}}},{$project:{_id:0,data_id:"$_id",/** If you want to aggregate for all data_ids*/days:{$arrayToObject:"$days"}}}])

Result