I store price changes data for each date in MongoDB as following:
{ "_id" : "A1",
"Price" :
{
"2020-08-25": {"P" : [1200, 1300, 1250]},
"2020-08-26": {"P" : [1310, 1400, 1200]},
"2020-08-27": {"P" : [1500, 1300, 1300]},
...
}
},
{ "_id" : "A2",
"Price" :
{
"2020-08-25": {"P" : [1200, 1300, 1250]},
"2020-08-26": {"P" : [1310, 1400, 1200]},
"2020-08-27": {"P" : [1500, 1300, 1300]},
...
}
}
Now, I want to get maximum price for all dates. How I can do it without writing each date field in my query? I mean, for a specific date like as "2020-08-25", someone can uses $group and $max to obtain maximum price value in that date. But, how write a query to get maximum price value among all dates?
Thanks