Question

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?

Était-ce utile?

La solution

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top