我在MongoDB中有一个文档
{
"_id" : ObjectId("5b1e2697073d4c172d5a362a"),
"trackingId" : "0050568a00bc",
"environment" : "QA",
"events" : [
{
"type" : "Status",
"event" : "Not Sent",
"eventDateTime" : ISODate("2018-06-19T08:04:22.603Z")
},
{
"type" : "Status",
"event" : "Ok",
"eventDateTime" : ISODate("2018-06-11T08:04:19.606Z")
},
{
"type" : "Status",
"event" : "Initial",
"eventDateTime" : ISODate("2018-06-11T07:36:55.632Z")
}
]
}
我可以通过跟踪ID和环境db.getCollection('app.logging').find({"trackingId":"0050568a00bc", "environment":"QA"})
如何仅更新第一个eventDateTime
的{{1}}?它必须与events
,$push
或$slice
一起使用吗?