mongodb pymongo:
有两条记录是这样
{"a":"BBB" , "b":[ {"b11": "b11value" ,"b12":"b12value"} , { "b21":"b21value" , "b22":"b22value" } ]}
我想更新a为AAA且b中b11的值为b11value的值为b11111111value:
结果应该是这样:
{"a":"BBB" , "b":[ {"b11": "b11value" ,"b12":"b12value"} , { "b21":"b21value" , "b22":"b22value" } ]}
以及把a为AAA且b中b11的值为b11value的(b11删除)
结果应该是这样:
{"a":"BBB" , "b":[ {"b11": "b11value" ,"b12":"b12value"} , { "b21":"b21value" , "b22":"b22value" } ]}
一个更新,一个是删除
这两个怎么写?
sql语句应该怎么写?谢谢
In the example,
c
is your collection name.First one:
Second one:
Used
$elemMatch
,$set
,$pull
three modifiers.