0

I need to pull all the objectids inside the array of each documents, field variables is an array in the collection .

db.users.variables.update({},{$pull:{variables:{$in:invalidVariables}}},
                             {safe:true, multi:true, upsert:false});

This is the query I am using. But it pulls all the values from the single document.I have mentioned multi true also. What can be a issue.Please help me

Neo-coder
  • 7,715
  • 4
  • 33
  • 52
Soorya Prakash
  • 921
  • 3
  • 9
  • 29

1 Answers1

1

What version of MongoDB are you using? Can we see your document structure? The following two queries should both work (in 2.6.5) and should do what it seems like you want to do:

db.users.variables.update({ }, { "$pull" : { "variables" : { "$in" : [1, 2, 3] } } }, { "multi" : true })

db.users.variables.update({ }, { "$pullAll" : { "variables" : [1, 2, 3] } }, { "multi" : true })
wdberkeley
  • 11,531
  • 1
  • 28
  • 23