0
我試圖更新我的整個數據庫中的每個會議的值。目前,它看起來像這樣:MongoCollection更新,其中的值等於
{
"Referent" : null
"Participants" : [
{
"Email" : "[email protected]",
"Present" : true
},
{
"Email" : "[email protected]",
"Present" : false
},
{
"Email" : "[email protected]",
"Present" : true
}
]
}
我希望這種情況發生:
if(meeting.Referent == null) {
foreach(var participant in meeting.Partipants) {
if(participant.Present) {
meeting.Referent = participant.Email;
}
}
}
顯然上面的代碼不會對MongoCollection工作,但我希望這是有道理的。我想爲會議中出席的隨機(第一位或最後一位)參與者設定會議參考。
我該怎麼做,使用MongoCollection,所以我可以在我的Mongo Shell中運行它?