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

insertMany throws error when docs is empty array

    • 1

      Collection.insertMany throws an error when docs passed is an empty array.
      It should instead call the callback with the same error.

      Example:

      const { MongoClient } = require('mongodb');
      
      MongoClient.connect('mongodb://localhost:27017/test', (err, db) => {
        if (err) {
          return console.log('MONGO CONNECTION ERR');
        }
      
        db.collection('users').insertMany([], (err, result) => {
          if (err) {
            return console.log('The error should be thrown here instead', err);
          }
        });
      });
      

            Assignee:
            matt.broadstone@mongodb.com Matt Broadstone
            Reporter:
            kikar Gady Piazza
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: