3

When I try to add some Documents to a Collection, exactly 1 of 4 times I get an Error.

for (var i = 0; i < 50; i=i+1){
    db.SampleOrder.insert(
    {
        "SampleId": NumberInt(i),
        "PuckId": NumberInt(i)
    });  
}

Error: Picture of the Error

Does anybody know why this doesn't work? I use Robomongo Robo 3T 1.1.1.

noscript
  • 77
  • 1
  • 12
  • Might want to report it to Robomongo. And add details of the tool version used by you specifically. – Naman Aug 30 '17 at 07:48

1 Answers1

0

you can use insertMany instead of insert to insert multiple document

like:

var docs = [];
for (var i = 0; i < 50; i=i+1){
    docs.push({
        "SampleId": NumberInt(i),
        "PuckId": NumberInt(i)
        });
}
db.SampleOrder.insertMany(docs);
Shaishab Roy
  • 16,335
  • 7
  • 50
  • 68
  • thanks for the answer. But my loop isn't finsh like this. It's some kind of a Bug from MongoDB / Robomongo. When I know what exactly triggers the Bug I will post It. Fact when I've opened a new shell the error was gone with the same loop. And a little later the Error was there again but I think it's a combination from things. – noscript Aug 30 '17 at 09:27