How to remove the nth element of an array with morphine

For example, I have a document

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

and I need to remove the item with the key "c" from the list.

With the mongo console command, I do this and delete the correct key

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

Is there any way to do this with morphine?

+4
source share
1 answer

Take a look at UpdateOperations.removeAll (java.lang.String, java.lang.Object) I think you will get what you need.

+5
source

Source: https://habr.com/ru/post/1527930/


All Articles