E-commerce platform, how is the monthly sales of goods calculated?

  mongodb, question

For example, the total sales volume in a month is 500 pieces, the sales volume on February 1 is 11 pieces, but it is only 10 pieces on March 1, then after March 1, the total sales volume will become 499 pieces.
Is it to write a regular task that is updated every morning, counting the sales volume of each month according to the first 30 days from today? Can I still count monthly sales in real time?

By the same token, how are the monthly views of general videos or articles counted?

Although I can’t fully understand what you mean, I do it sometimes. For example:

{product: String,
 Sales volume: [{date:' March 1', sales volume: 100},
 {date:' March 2', sales volume: 50},
 ...
 ....
 ],
 Total sales: number
 }

Summary sales can be updated in real time using update+$inc

For reference.

Love MongoDB! Have fun!