Unordered bulk inserts return an additional null value for insertedIds

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Minor - P4
    • 2.2.25
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      reproduction code:

      const MongoClient = require('mongodb').MongoClient;
      MongoClient.connect('mongodb://localhost', (err, db) => {
        let test = db.collection('test');
        return test.insert([{a: 1}, {a: 1}, {a: 1}, {a: 1}, {a: 1}, {a: 1}])
          .then(result => console.log(result.insertedIds.length))
          .then(() => db.close());
      });
      

      This is the same as a call to `test.insertMany(<data>,

      { ordered: false }

      `, which also returns 7 inserted ids due to the fact that the internal representation of the ids is 1-indexed (rather than starting at 0).

              Assignee:
              Christian Amor Kvalheim
              Reporter:
              Matt Broadstone
              None
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: