0

Is it possible to $pull from 2 array fields in a document : for example if i have a doc as listed below :

{
  "_id" : "376123123731223812312376",
  "array1" : [{
      "field1" : "0000000",
      "field2" : 1,
      "field3" : "foo1"
    }],
  "createdat" : 1411068136599,
  "updatedat" : 1413198791350,
  "array2" : ["value1","value2"]
}

Can i do something like :

var update  = {'$pull':{'array1':{'field1':'0000000'},'array2':{"value2"}}};

The above is giving a syntax err so i was wondering if it can be done ?

Neo-coder
  • 7,715
  • 4
  • 33
  • 52
thegrid
  • 509
  • 1
  • 6
  • 20

1 Answers1

0

Ok so i found that i was using the wrong notation. The array2 is just an array of string so the solution is

var update = {'$pull':{'array1':{'field1':'0000000'},'array2':"value2"}};

thegrid
  • 509
  • 1
  • 6
  • 20