For example i have a document

{
_id: 1, 
list:[
    {
      key: "a",
      "value":"ssss"
     },
    {
      key: "b",
      "value":"ssss"
     },
     {
      key: "c",
      "value":"ssss"
     },
]
}

and i need remove element with "c" key from the list.

With mongo console command i make like this and remove correct key

db.test.update({{_id: 1},{"$pull" : {"list" : { "key" : "c"}}},false,false)

there is a way to do it with morphia?

有帮助吗?

解决方案

Look at UpdateOperations.removeAll(java.lang.String, java.lang.Object) I think that'll get you what you need.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top