From deaa95b4b81213a2be46484eaf9cee1321cc3da7 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Fri, 30 Dec 2016 20:32:58 -0700 Subject: [PATCH] fix(model): allow passing non-array to insertMany Fix #4846 --- lib/model.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/model.js b/lib/model.js index 95f0a0d06d5..59ce712eb4d 100644 --- a/lib/model.js +++ b/lib/model.js @@ -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) {