Created
April 10, 2013 20:04
-
-
Save watson/5357966 to your computer and use it in GitHub Desktop.
This code will result in 9 "E11000 duplicate key error index" errors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var dbUri = '...'; | |
| var db = require('mongojs').connect(dbUri, ['testing']); | |
| var data = { foo: 1 }; | |
| for (var n = 0; n < 10; n++) { | |
| db.testing.insert(data, function (err, res) { | |
| if (err) console.log(err.message); | |
| }); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The issue seems to be that mongojs adds an
_idattribute to thedataobject, which is then reused after the first insert