Database
[{"_id":ObjectId("64a9187ebf818c011338e269"),"amount":3005.159195643119,"transactionType":"add","createdAt":"2023-07-08T08:04:14.674+0000"},{"_id":ObjectId("64a9187ebf818c011338e26a"),"amount":7187.292634789364,"transactionType":"withdraw","createdAt":"2023-07-08T08:04:14.674+0000"},{"_id":ObjectId("64a9189ebf818c011338e26b"),"amount":6532.400083578514,"transactionType":"add","createdAt":"2023-07-08T08:04:46.922+0000"},{"_id":ObjectId("64a9189ebf818c011338e26c"),"amount":4322.73446781267,"transactionType":"withdraw","createdAt":"2023-07-08T08:04:46.922+0000"},{"_id":ObjectId("64a9189fbf818c011338e26d"),"amount":3978.3831513179125,"transactionType":"add","createdAt":"2023-07-08T08:04:47.428+0000"},{"_id":ObjectId("64a9189fbf818c011338e26e"),"amount":9182.22651062747,"transactionType":"withdraw","createdAt":"2023-07-08T08:04:47.428+0000"},{"_id":ObjectId("64a9189fbf818c011338e26f"),"amount":5146.639407782618,"transactionType":"add","createdAt":"2023-07-08T08:04:47.940+0000"},{"_id":ObjectId("64a9189fbf818c011338e270"),"amount":6948.495922556086,"transactionType":"withdraw","createdAt":"2023-07-08T08:04:47.940+0000"},{"_id":ObjectId("64a918a0bf818c011338e271"),"amount":5903.399758975769,"transactionType":"add","createdAt":"2023-07-08T08:04:48.451+0000"},{"_id":ObjectId("64a918a0bf818c011338e272"),"amount":9586.684497379856,"transactionType":"withdraw","createdAt":"2023-07-08T08:04:48.451+0000"},{"_id":ObjectId("64a918a0bf818c011338e273"),"amount":4957.875146648247,"transactionType":"add","createdAt":"2023-07-08T08:04:48.963+0000"},{"_id":ObjectId("64a918a0bf818c011338e274"),"amount":5949.8072593175075,"transactionType":"withdraw","createdAt":"2023-07-08T08:04:48.963+0000"},{"_id":ObjectId("64a918a1bf818c011338e275"),"amount":6829.357484527203,"transactionType":"add","createdAt":"2023-07-08T08:04:49.474+0000"},{"_id":ObjectId("64a918a1bf818c011338e276"),"amount":7710.326853670482,"transactionType":"withdraw","createdAt":"2023-07-08T08:04:49.474+0000"},{"_id":ObjectId("64a918a1bf818c011338e277"),"amount":2477.8703825774205,"transactionType":"add","createdAt":"2023-07-08T08:04:49.985+0000"},{"_id":ObjectId("64a918a1bf818c011338e278"),"amount":6849.108139771325,"transactionType":"withdraw","createdAt":"2023-07-08T08:04:49.985+0000"},{"_id":ObjectId("64a918a2bf818c011338e279"),"amount":4694.309123233315,"transactionType":"add","createdAt":"2023-07-08T08:04:50.496+0000"},{"_id":ObjectId("64a918a2bf818c011338e27a"),"amount":9803.09388395046,"transactionType":"withdraw","createdAt":"2023-07-08T08:04:50.496+0000"},{"_id":ObjectId("64a918a3bf818c011338e27b"),"amount":6118.890189055924,"transactionType":"add","createdAt":"2023-07-08T08:04:51.007+0000"},{"_id":ObjectId("64a918a3bf818c011338e27c"),"amount":7982.25720431178,"transactionType":"withdraw","createdAt":"2023-07-08T08:04:51.007+0000"},{"_id":ObjectId("64a918a3bf818c011338e27d"),"amount":2604.0447612047756,"transactionType":"add","createdAt":"2023-07-08T08:04:51.519+0000"},{"_id":ObjectId("64a918a3bf818c011338e27e"),"amount":9293.429120888763,"transactionType":"withdraw","createdAt":"2023-07-08T08:04:51.519+0000"}]
Query
db.collection.aggregate([{$group:{_id:"$createdAt",transactions:{$push:{type:"$transactionType",totalAmount:"$amount"}}}},{$project:{_id:0,date:"$_id",transactions:1}}])