how to ignore duplicate documents when using insertMany in mongodb php library?
问题 I am using mongo php library, and trying to insert some old data into mongodb. I used insertMany() method and pass a huge array of document, that may have duplicate documents on unique indexes. Lets say I have a users collection and have these indexes: [ { "v" : 1, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "test.users" }, { "v" : 1, "unique" : true, "key" : { "email" : 1 }, "name" : "shop_id_1_title_1", "ns" : "test.users" } ] If there's a duplicate document, MongoDB\Driver\Exception