MongoDB Correct Schema for aggregated data

后端 未结 4 1191
旧时难觅i
旧时难觅i 2020-12-22 05:31

I have a big collection that holds lots of stats, since I want to generate reports, I am running a daily cron which aggregates data from the main collection to a smaller one

4条回答
  •  感情败类
    2020-12-22 05:55

    This schema simplify a lot range queries and array is a common way of store these data series.

    {
        'order_id': 'VjprK',
        'user_id': '777',
        'data': [
            {
                date: MongoDate(2015-04-18),
                value: 100
            },
            {
                date: MongoDate(2015-04-19),
                value: 200
            }
            ...
        ]
    }
    

提交回复
热议问题