>>> db.mydb.insertMany([{"k1":"v1","k2":"v2","_id":2},{"k1":"v1","_id":2},{"k2":"v2"}])2021-02-23T00:06:20.219+0800 E QUERY [js] uncaught exception: BulkWriteError({ "writeErrors" : [ { "index" : 1, "code" : 11000, "errmsg" : "E11000 duplicate key error collection: test.mydb index: _id_ dup key: { _id: 2.0 }", "op" : { "k1" : "v1", "_id" : 2 } } ], "writeConcernErrors" : [ ], "nInserted" : 1, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ]}) :BulkWriteError({ "writeErrors" : [ { "index" : 1, "code" : 11000, "errmsg" : "E11000 duplicate key error collection: test.mydb index: _id_ dup key: { _id: 2.0 }", "op" : { "k1" : "v1", "_id" : 2 } } ], "writeConcernErrors" : [ ], "nInserted" : 1, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ]})BulkWriteError@src/mongo/shell/bulk_api.js:367:48BulkWriteResult/this.toError@src/mongo/shell/bulk_api.js:332:24Bulk/this.execute@src/mongo/shell/bulk_api.js:1186:23DBCollection.prototype.insertMany@src/mongo/shell/crud_api.js:326:5@(shell):1:1>>>>>> db.mydb.find(){ "_id" : 0 }{ "_id" : 1 }{ "_id" : ObjectId("6033d499a645f64a043ff03c"), "key1" : "value1", "key2" : "value2" }{ "_id" : ObjectId("6033d499a645f64a043ff03d"), "key1" : "value3" }{ "_id" : ObjectId("6033d499a645f64a043ff03e"), "key2" : "value4" }{ "_id" : 2, "k1" : "v1", "k2" : "v2" }>>>>
评论