Skip to content

Commit

Permalink
fix(model): allow passing non-array to insertMany
Browse files Browse the repository at this point in the history
Fix #4846
  • Loading branch information
vkarpov15 committed Dec 31, 2016
1 parent a5150d6 commit deaa95b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/model.js
Expand Up @@ -1930,6 +1930,10 @@ Model.insertMany = function(arr, callback) {
callback = this.$wrapCallback(callback);
}

if (!Array.isArray(arr)) {
arr = [arr];
}

var toExecute = [];
arr.forEach(function(doc) {
toExecute.push(function(callback) {
Expand Down

0 comments on commit deaa95b

Please sign in to comment.