在Mongo中提供了以下文档:
[
{
"_id": "1",
"prices": {
"2024-01-01 00:00:00": "11",
"2024-01-02 00:00:00": "22",
"2024-01-03 00:00:00": "33"
},
}
{
"_id": "2",
"prices": {
"2024-01-03 00:00:00": "33",
"2024-01-04 00:00:00": "44",
"2024-01-05 00:00:00": "55"
}
}
]
我需要支持两项操作:
- 按日期更新价格元素(例如,设置
"$.prices.2024-01-01 00:00:00" = 100
). - 删除
prices
对象中具有关键日期条件的所有元素(例如,删除其中$.prices.key <= "2024-01-01 00:00:00"
的所有元素).
我不确定如何使用Mongo高效地进行第二次操作.有什么主意吗?