insertMany throws error when docs is empty array

XMLWordPrintableJSON

    • 1
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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
              Reporter:
              Gady Piazza
              None
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: