skip to Main Content

MongoDB: Upsert with array filter

I have collection like this: mc.db.collection.insert_many([ {"key_array": [1], "another_array": ["a"]}, {"key_array": [2, 3], "another_array": ["b"]}, {"key_array": [4], "another_array": ["c", "d"]}, ]) And I'm using this kind of updates: mc.db.collection.update_one( {"key_array": 5}, {"$addToSet": {"another_array": "f"}}, upsert=True ) It works good with…

VIEW QUESTION
Back To Top
Search