Remove a field from all elements in array in mongodb

  • Thread starter Thread starter Anonymous
  • Start date Start date
A

Anonymous

Guest
I have document in MongoDB(2.4.5)

I want to remove withBase filed from array elements inside casts.crew ..

I tried this

Code:
db.coll.update({_id:235399},{$unset: {  "casts.crew.withBase" : 1 } },false,true)
nothing changed.

And tried this..

Code:
db.coll.update({_id:235399},{$unset: {  "casts.crew" : { $elemMatch: { "withBase": 1 } } } },false,true)
it removed entire crew array from the document.

Can someone please provide me the right query?
 
Back
Top