我有以下文件:
class Person{
String id;
HashMap<String, Person> friends = new HashMap<>();
public void addFriend(String id, Person friend){
friends.put(id, friend);
}
...
}
HashMap<String, Person> people = new HashMap<>();
我需要按键"parameters" : [
{
"592193d6470e6cf80d3c9874" : {
"Speed" : "1",
"Acceleration" : "2"
}
}]
拉取元素。
我试过了:
592193d6470e6cf80d3c9874
$this->collection->update(
[],
['$unset' => ['parameters' => $id]], ['multiple' => true]);
id $id
。
答案 0 :(得分:1)
$this->collection->update(['$unset' => ['parameters'=> ['_id'] => $id], ['multiple' => true]);
或
$this->collection->update(['$unset' => ['parameters.'.$parameterId => null]], ['multiple' => true]);