I have a very basic question on updating a mongo collection.
Suppose I have a mongo document like this:
{"Object_id:.....,"product_id":1234, "color":0}
{"Object_id:.....,"product_id":1234, "color":1} # note the same product_id
{"Object_id:.....,"product_id":12345, "color":0}
Now what i want is:
if product_id == 1234 and color == 1:
# modify that document to color = 2
after update
{"Object_id:.....,"product_id":1234, "color":0}
{"Object_id:.....,"product_id":1234, "color":2} # note the same product_id
{"Object_id:.....,"product_id":12345, "color":0}
To literally do what you want it would be:
If you had multiple occurrences of product_id == 1234 and color == 1 and you wanted to update them all if found, then it is: