From 2350c1d72d8c0648575252879b670e8328a9a94f Mon Sep 17 00:00:00 2001 From: Andreas Eberhard Date: Thu, 1 Sep 2016 11:53:12 +0200 Subject: [PATCH] ADD: removeMany case to _run function # FIX If you had run till now with something like: `db._run('remove', 'collectionName', { myKey: 'string' });` you couldn't remove many documents. The code to delete many implied to use it as: `db._run('remove', 'collectionName', [{ myKey: 'string' }]);` (check for `util.isArray(options)`) but that would throw an error [1]. To keep current code running and not to break stuff I introduced the `removeMany`: `db._run('removeMany', 'collectionName', { myKey: 'string' })` 1: [db.collection.deleteMany()](https://docs.mongodb.com/manual/reference/method/db.collection.deleteMany/) --- index.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 1ecbbfa..df248f6 100644 --- a/index.js +++ b/index.js @@ -325,12 +325,11 @@ var MongodbDriver = Base.extend({ else db.collection(collection).insertOne(options, {}, callbackFunction); break; + case 'removeMany': + db.collection(collection).deleteMany(options, callbackFunction); + break; case 'remove': - // options is the records to insert in this case - if(util.isArray(options)) - db.collection(collection).deleteMany(options, callbackFunction); - else - db.collection(collection).deleteOne(options, callbackFunction); + db.collection(collection).deleteOne(options, callbackFunction); break; case 'collections': db.collections(callbackFunction);