0
我有一個集合
users
{
"_id" : ObjectId("53738eb7ac8ee07007c1d75a"),
"first" : "Shivam",
"connections" : [
{
"invit_made" : [ ],
"fl_no" : 615,
"date" : ISODate("2014-05-16T00:00:00Z"),
"fl" : "LB",
"TYP" : "ZLP",
"invit_reciv" : [ ],
},
{
"invit_made" : [ ],
"fl_no" : 615,
"date" : ISODate("2014-05-20T00:00:00Z"),
"fl" : "LB",
"invit_reciv" : [ ],
"TYP" : "ZLP",
}
]
}
我進行更新accoding迄今在connections.but錯誤的嵌套記錄在我的情況下被更新。
db.users.update(
{ 'connections.TYP' : 'ZLP'
,'connections.fl' : 'LB'
,'connections.date' : ISODate("2014-05-20T00:00:00Z")
},
{ '$addToSet' : {
'connections.$.invit_reciv' : { 'last' : 'abc'}
}
})
實際結果我得到。
{
"_id" : ObjectId("53738eb7ac8ee07007c1d75a"),
"first" : "Shivam",
"connections" : [
{
"invit_made" : [ ],
"fl_no" : 615,
"date" : ISODate("2014-05-16T00:00:00Z"),
"fl" : "LB",
"TYP" : "ZLP",
"invit_reciv" : [
{
"last" : "abc"
}
],
},
{
"invit_made" : [ ],
"fl_no" : 615,
"date" : ISODate("2014-05-20T00:00:00Z"),
"fl" : "LB",
"invit_reciv" : [ ],
"TYP" : "ZLP",
}
]
}
結果我想到
{
"_id" : ObjectId("53738eb7ac8ee07007c1d75a"),
"first" : "Shivam",
"connections" : [
{
"invit_made" : [ ],
"fl_no" : 615,
"date" : ISODate("2014-05-16T00:00:00Z"),
"fl" : "LB",
"TYP" : "ZLP",
"invit_reciv" : [ ],
},
{
"invit_made" : [ ],
"fl_no" : 615,
"date" : ISODate("2014-05-20T00:00:00Z"),
"fl" : "LB",
"invit_reciv" : [
{
"last" : "abc"
}
],
"TYP" : "ZLP",
}
]
}
請幫助我瞭解什麼是當前查詢發生的,什麼是錯的。