Find and remove array value using mongoDB

Viewed 19

This is the data I want to find using device array value 1 for and that object and removes that value from the device array.

find using device array value 1 and remove that value from the array

This is my current object:

[ 
 {
    "devices": [
      "1",
      "2"
    ],
    "eui": "A5AC840871F01D65",
    "key": "5BCBF770D2B43638860F7DA3733ED1B3",
    
  },
  {
    "devices": [
      "3",
      "4"
    ],
    "eui": "A5AC840871F01D65",
    "key": "5BCBF770D2B43638860F7DA3733ED1B3",
    
  }
]

the expected output is :

 {
    "devices": [
      "2"
    ],
    "eui": "A5AC840871F01D65",
    "key": "5BCBF770D2B43638860F7DA3733ED1B3",
    
  },
  {
    "devices": [
      "3",
      "4"
    ],
    "eui": "A5AC840871F01D65",
    "key": "5BCBF770D2B43638860F7DA3733ED1B3",
    
  }
]
1 Answers
Related