Is there a way of telling MongoDB to skip (instead of crashing) if we want to insert a document which has the same _id
as an existing one?
Say, I have this list and I want to persist it:
to_mongo = [
{'_id': 'aaaaaa', 'content': 'hey'},
{'_id': 'bbbbbb', 'content': 'you'},
{'_id': 'aaaaaa', 'content': 'hey'}
]
mongo_collection.insert_many(to_mongo)
I'd like the last item to be simply ignored, instead of causing the whole request to crash.