尝试更新嵌套数组

时间:2019-03-20 14:18:21

标签: arrays mongodb

我正在尝试更新一个已经存在的阵列。我可以找到该数组,但是无法更新它。我正在尝试使用$ arrayElemAt选择数组的最后一个元素,但我认为我不正确理解它的用法。 这是我想要实现的目标:

之前:

{
 "_id": "5c9246c78563a42a7e3f0097",
 "Game": [
   {
     "Id": "281e192bb7d1b29c4be10f6f257e11ae",
         "Question": "Une question pertinente",
         "Initial_balance": 1000
       }
     ]
    }

之后:

{
 "_id": "5c92231e8c461e222e0264df",
 "Game": [
   {
     "Id": "281e192bb7d1b29c4be10f6f257e11ae",
     "Question": "Une question pertinente",
     "Initial_balance": 1000,
     "Rounds": [
       {
         "Id": "1234",
         "Date": "0000",
         "Propositions": [
           {
             "Id": "1234",
             "Uid": "U123",
             "String": "abcd",
             "Bool": "true"
           }
         ]
       }
     ]
   }
 ]
}

谢谢

0 个答案:

没有答案