0

Can I use any in mongoDB $addToSet?

{ $addToSet: { critters: { id: id_critter, amount: $ }

I would like to check if only id_critter is the same, amount can be different.

Neil Lunn
  • 148,042
  • 36
  • 346
  • 317
Pikachu
  • 1,973
  • 3
  • 20
  • 27
  • 1
    No you cannot as that truly would not be a "set". You can only do this by implementing some custom logic that would check all the `id` values within the "critters" sub-document. And typically that means retrieving the document and checking that in code. – Neil Lunn May 14 '14 at 08:56
  • Damn! I thought I'm in home. Thanx for the answer. – Pikachu May 14 '14 at 08:57

0 Answers0