mongo コレクションの更新に関する非常に基本的な質問があります。
次のような mongo ドキュメントがあるとします。
{"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}
今私が欲しいのは:
if product_id == 1234 and color == 1: # そのドキュメントを color = 2 に変更します
更新後
{"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}