0
我的收藏是這樣的:
{
"_id" : ObjectId("597c4c42398593a7b464fc9c"),
"userId" : NumberLong(2),
"steps" : [
{
"_id" : ObjectId("597c4c42398593a7b464fc9a"),
"beginningDate" : "2017-07-29T13:20:10.344",
"state" : "Pending",
"messages" : [
{
"_id" : ObjectId("597c4c42398593a7b464fc9b"),
"content" : "Hi",
"isRead" : 0,
"side" : "UserToAdmin",
"creationDate" : "2017-07-29T13:20:10.344"
}
]
},
{
"_id" : ObjectId("597c4ce5398593aaa897ccb4"),
"beginningDate" : "2017-07-29T13:22:53.884",
"state" : "Open",
"messages" : []
}
],
"lastStepState" : "Pending",
"lastModified" : "2017-07-29T13:26:36.774"
}
什麼基本上,我試圖做的是,每當我推一個新的臺階進入步驟陣,我在下面的方式更新lastStepState:
Document updateQueryDoc = new Document("userId", userId).append("lastStepState",
new Document("$eq", State.Pending.name()));
Document updateDoc = new Document("$push", new Document("steps", newStepDoc))
.append("$set", new Document("lastStepState", State.Open.name()))
.append("$set", new Document("lastModified", now));
(狀態與等待和開放值的枚舉) 然而,lastStepState不會被更新。可能是什麼問題呢? (我還要提到的是有集合中的一個文件,所以使用updateMany不是soultion我的問題。)