-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.2.30
-
Component/s: MongoDB 3.2, MongoDB 3.4
-
1
-
Empty show more show less
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); } }); });