Database

[{"_id":{"$oid":"6354f982a11464ff4f7bac60"},"userId":{"$oid":"6353aa119d39ccbb3263123f"},"date":"2022-10-23","base64":"data:image/png;base64,iVBORw0KGgoAAA....=","label":"monthTen","uriPath":"xxxx","s3Path":"xxxx","amount":0,"__v":0,"type":"tva"},{"_id":{"$oid":"6354fbf4391eef24318802c6"},"userId":{"$oid":"6353aa119d39ccbb3263123f"},"date":"2022-09-10","base64":"data:image/png;base64,iVBORw0KGgoAAA....=","label":"monthNineFirst","uriPath":"xxxx","s3Path":"xxxx","amount":0,"__v":0,"type":"tva"},{"_id":{"$oid":"62fcd87cea9afdcec70f25ab"},"userId":{"$oid":"6353aa119d39ccbb3263123f"},"date":"2022-09-19","base64":"data:image/png;base64,iVBORw0KGgoAAA....=","label":"monthNineSecond","uriPath":"xxxx","s3Path":"xxxx","amount":0,"__v":0,"type":"tva"}]

Query

db.collection.aggregate([{$group:{_id:{$month:{$dateFromString:{dateString:"$date",format:"%Y-%m-%d"}}},data:{$push:"$$ROOT"}}}])

Result