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

insertMany throws error when docs is empty array

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Works as Designed
    • Affects Version/s: 2.2.30
    • Fix Version/s: None
    • Component/s: MongoDB 3.2, MongoDB 3.4
    • Labels:
      None
    • Story Points:
      1

      Description

      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);
          }
        });
      });
      

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: