同一文档中相同数组元素的同一MongoDB更新中的$ push和$ set

时间:2018-06-21 17:46:49

标签: mongodb mongodb-query mongo-java-driver

文档结构如下-

{
    "nestedDocArray" : [ 
        {
            "a" : "a",
            "b" : "b",
            "c" : "c",
            "createdOn" : ISODate("2018-06-19T08:38:34.228Z")
        }, 
        {
            "a" : "a1",
            "b" : "b1000",
            "c" : "c1",
            "createdOn" : ISODate("2018-06-19T08:38:34.233Z")
        }, 
        {
            "a" : "a1000",
            "b" : "b1000",
            "c" : "c1000",
            "createdOn" : ISODate("2018-06-21T10:54:30.679Z")
        }
    ]
}

如果我尝试在单个更新语句中对相同的nestedDocArray属性执行$ push,$ pull和$ set,则会导致异常“更新路径'nestedDocArray'将在'nestedDocArray'上造成冲突”“ < / p>

0 个答案:

没有答案