0

here is a document in mongo:

{ 
  _id: objectid,
  user: objectid,
  company: objectid,
  groups:[
    {items:['a','b']}, {items:['c','d']}
  ]
}

then, i got a array:

 ['a','c']

i want to pull this array from above document and i want to operate above document , finally i want the above document be like this:

{ 
  _id: objectid,
  user: objectid,
  company: objectid,
  groups:[
    {items:['b']}, {items:['d']}
  ]
}

how to get this result in mongo

i'm desire helps

thanks.

J.Gea
  • 25
  • 5
  • I don't think you can make that kind of query natively in Mongo. Just pull your document, then filter `groups` according to your needs, and pass the altered document. – Jeremy Thille Oct 26 '17 at 07:31
  • @JeremyThille sorry, i may not describe the question clear or you made me confused, i edited my question again , i want to use the array ['a','c'] to operate the above document , change the above document to become i wanted in one step , i beg your help and patience, thank you very much. – J.Gea Oct 26 '17 at 07:42
  • Oh, so you want to pull it, alter it and then re-save it? I didn't get that indeed. But it looks like your question is a duplicate, follow the link above, it'll help you. – Jeremy Thille Oct 26 '17 at 07:49
  • @JeremyThille you got it and thank you, i will follow the link above – J.Gea Oct 26 '17 at 07:55

0 Answers0