0
下面的查詢由MongoDB的蒙戈DB更新操作
錯誤地更新查詢:
d.update({'Objects.out.interface': 'down', 'IP': '192.168.106.11', 'INID': 19, 'SESSION': 1, 'Objects.id': 4}, {$set: {'Objects.$.score':888888}})
爲什麼我的成績在888888不Objects.id:2在Objects.id:4更新?
更新結果:
{
"_id" : ObjectId("59b7ebec9315080ac2801468"),
"SESSION" : 1,
"INID" : 19,
"IP" : "192.168.106.11",
"Hostname" : "Npppp",
"JOBNAME" : "Nexus2-12-September-19-45-08",
"Authentication" : "{\"username\":\"gowtham\",\"password\":\"pppppp\"}",
"Objects" : [
{
"name" : "self",
"out" : {
"status" : "reachable"
},
"type" : "self_check",
"id" : 1,
"rank" : [
{
"regex" : {
"status" : "down"
},
"score" : 0
},
{
"regex" : {
"status" : "reachable"
},
"score" : 100
}
],
"monitor" : "self",
"score" : 100
},
{
"name" : "Eth1/1",
"out" : {
"interface" : "down"
},
"type" : "cis_sw_int",
"id" : 2,
"rank" : [
{
"regex" : {
"interface" : "down"
},
"score" : 0
},
{
"regex" : {
"interface" : "up"
},
"score" : 100
}
],
"monitor" : "bits,duplex,speed,error",
"score" : 888888
},
{
"name" : "Eth1/37",
"out" : {
"interface" : "down"
},
"type" : "cis_sw_int",
"id" : 3,
"rank" : [
{
"regex" : {
"interface" : "down"
},
"score" : 0
},
{
"regex" : {
"interface" : "up"
},
"score" : 100
}
],
"monitor" : "bits,duplex,speed,error"
},
{
"name" : "Eth1/46",
"out" : {
"interface" : "down"
},
"type" : "cis_sw_int",
"id" : 4,
"rank" : [
{
"regex" : {
"interface" : "down"
},
"score" : 0
},
{
"regex" : {
"interface" : "up"
},
"score" : 100
}
],
"monitor" : "bits,duplex,speed,error"
}
],
"timeout" : 10,
"TD" : ISODate("2017-09-12T19:45:08.743Z")
}
嘗試沒有'「Objects.out.interface」:「down''。結果是什麼? – Rumoku
同樣的結果,因爲兩個對象都有'down' – user3041095
@ user3041095,這是不正確的。如果你刪除''Objects.out.interface':'down'',它會更新id爲4的那個。 –