mongodb - e-commerce platform, how is the monthly sales volume of products calculated?
巴扎黑
巴扎黑 2017-05-17 10:02:35
0
1
859

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?

巴扎黑
巴扎黑

reply all(1)
世界只因有你

Although I don’t fully understand what you mean, this is how it is done sometimes. For example:

{ 产品:String,
  销量:[{日期:'3月1日',销量:100},
        {日期:'3月2日',销量:50},
        ...
        ....
        ],
  总计销量:number
}

The summary sales volume can be updated in real time using update + $inc.

For reference.

Love MongoDB! Have fun!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template