I store millions of price change data for various items in "Price" array in MongoDB like as:
{
"item" : "I1",
"Price" : [
{"k": "2020-07-01", "v": [{"t":t1, "v":1000}, {"t":t2, "v":1500}, {"t":t3, "v":1350}, ..]},
{"k": "2020-07-02", "v": [{"t":t1, "v":1200}, {"t":t2, "v":1250}, {"t":t3, "v":1050}, ..]},
...
]
},
{
"item" : "I2",
"Price" : [
{"k": "2020-07-01": [{"t":t1, "v":1025}, {"t":t2, "v":1200}, {"t":t3, "v":1400}, ..]},
{"k": "2020-07-02": [{"t":t1, "v":1560}, {"t":t2, "v":1050}, {"t":t3, "v":1350}, ..]},
...
]
}
I just wondering is there any way to push a new time-price for example {"t": t', "v": 2000} in Price array's element with a specific key, such as "k": "2020-07-01"? The result for item "I1" should be like as:
{
"item" : "I1",
"Price" : [
{"k": "2020-07-01", "v": [{"t":t1, "v":1000}, {"t":t2, "v":1500}, {"t":t3, "v":1350}, .., {"t":t', "v":2000}]},
{"k": "2020-07-02", "v": [{"t":t1, "v":1200}, {"t":t2, "v":1250}, {"t":t3, "v":1050}, ..]},
...
]
},
Thanks