Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-950

Unordered bulk inserts return an additional null value for insertedIds

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.2.25
    • Affects Version/s: None
    • Component/s: 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:
            christkv Christian Amor Kvalheim
            Reporter:
            matt.broadstone@mongodb.com Matt Broadstone
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: