0

Mongo Playground

Simple Schema:

[
  {
    "key": 1,
    "Array": [
      {
        "Prop1": 1,
        "Prop2": 2
      },
      {
        "Prop1": 2,
        "Prop2": 3
      },
      
    ]
  },
]

I want to update all child array, but mongo says 'The positional operator did not find the match needed from the query.'

db.collection.update({},
{
  "$set": {
    "Array.$.Prop1": ""
  }
},
{
  "multi": true,
  "upsert": false
})
2Fast4YouBR
  • 1,012
  • 1
  • 12
  • 22

1 Answers1

2

Maybe something like this:

 db.collection.update({},
 {
   "$set": {
     "Array.$[].Prop1": ""
    }
  },
  {
    "multi": true,
    "upsert": false
  })

playground

R2D2
  • 9,410
  • 2
  • 12
  • 28