Update same elements from differents array into same document

Hello ! I have a document as such :


{
"_id":{"$oid":"604e242c038a6aef974e61a4"},
"author":{"$oid":"603c08ff76c5cf37b82d2ba3"},
"title":"Alarme Web Mobile",
"licence":"Licence 2",
"lastUpdate":{"$date":{"$numberLong":"1616264648000"}},
"startedDate":{"$date":{"$numberLong":"1577833200000"}},
"stateProject":"En cours",
"tags":["multimedia","education","graphics","games","system","utilities"],
"sumup":"Ips",
"description":"Icici bonjour vidifszkfghsdlkfhgdsfhgkjldsfhjgdfnn le tan in",
"links":[
               {"title":"github","value":"http://projet.github.com"}, 
               {"title":"github","value":"http://projet.github.com"}, 
               {"title":"github","value":"http://projet.github.com"}, 
              {"title":"wiki","value":"http://monwiki.com"}
],
"jobs":[
           {
              "type":"developer",
              "requiredNb":{"$numberInt":"2"},
              "skills":["java","javascript","typescript"],
              "nameCollabPeople":[
                          {"name":"Philippe Bulot","_collab":{"$oid":"60578f742edbff32ee8f1c33"}}
              ]
           },
          {
           "type":"webmestre",
           "requiredNb":{"$numberInt":"2"},
           "nameCollabPeople":[
                     {"name":"Leslie Duciel","_collab":{"$oid":"60578fe82edbff32ee8f1c34"}},
                    {"name":"Philippe Bulot","_collab":{"$oid":"60578f742edbff32ee8f1c33"}}
             ]
          }
    ]
}

I’d like to remove the object from all nameCollabPeople that match a filter, here a name. Like so :

$pull:{'jobs.$.nameCollabPeople':{name:nameCollab}

But it does not work…
I found out how remove on object in one job document matching the type propertie and the name of the subdocument. But not all matching the name…

Could someone help me ?

Hi Preney
To update all the elements of an array use $[] instead of $

Let us know if it works
Greets

Hi !
Yes I finaly used $ instead and it worked in deed, after numerous of trials :smiley: !!!
I can go to bed without overthinking ! ^^

But Thank you for your answer anyway !!

Greets

1 Like

:laughing:
Have a good night

1 Like