Database

[{"_id":"636357777877c919bb2cfa45","products":[{"productId":"636355a07877c919bb2cdfdc","quantity":1,"sellerId":"636355187877c919bb2cdf1f","_id":"636357777877c919bb2cfa46"}],"amount":100,"createdAt":ISODate("2022-10-03T05:53:59.997Z"),},{"_id":"636357da7877c919bb2d035f","products":[{"productId":"636357387877c919bb2cf494","quantity":1,"sellerId":"636355187877c919bb2cdf1f","_id":"636357da7877c919bb2d0360"}],"amount":100,"createdAt":ISODate("2022-11-03T05:55:38.858Z"),"updatedAt":"2022-11-03T05:55:38.858Z","__v":0},{"_id":"636367d2407816df5f589bc6","products":[{"productId":"63635acf7877c919bb2d3d95","quantity":1,"sellerId":"636355187877c919bb2cdf1f","_id":"636367d2407816df5f589bc7"}],"amount":20,"createdAt":ISODate("2022-11-03T07:03:46.350Z"),}]

Query

db.collection.aggregate([{$match:{createdAt:{$gte:ISODate("2022-09-01T00:00:00.000Z")},products:{$elemMatch:{sellerId:"636355187877c919bb2cdf1f"}}}},{$project:{month:{$month:"$createdAt"},sales:"$amount"}},{$group:{_id:"$month",total:{$sum:"$sales"}}}])

Result