For example, the total sales volume in a month is 500 pieces. On February 1st, the sales volume was 11 pieces, but on March 1st, it was only 10 pieces. Then after March 1st, the total sales volume will become 499 pieces.
Write a scheduled task to update every morning, 30 days from today, and calculate monthly sales based on the order volume in the previous 30 days? Or can we count monthly sales in real time?
Similarly, how are the monthly views of general videos or articles calculated?
Although I don’t fully understand what you mean, this is how it is done sometimes. For example:
The summary sales volume can be updated in real time using update + $inc.
For reference.
Love MongoDB! Have fun!