From 6c31d5197fc5711c4b32b13697ec8741b8fde69b Mon Sep 17 00:00:00 2001 From: s-kazuki Date: Fri, 1 Feb 2019 11:29:36 +0900 Subject: [PATCH] update: outdated npms to fix audit suggestions and deprecated method in mongoose --- index.js | 22 ++++++++++++---------- package.json | 16 ++++++++-------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/index.js b/index.js index 591fae2..f7218ba 100644 --- a/index.js +++ b/index.js @@ -43,10 +43,10 @@ Seeder.prototype.connect = function(...params) { cb = params[1]; } else if (params.length == 3) { db = params[0]; - opts = params[1]; - cb = params[2]; + opts = params[1]; + cb = params[2]; } else { - console.error('Pass either 2 or 3 arguments to seeder.connect'); + console.error('Pass either 2 or 3 arguments to seeder.connect'); process.exit(1); } @@ -56,14 +56,16 @@ Seeder.prototype.connect = function(...params) { cb(); } else { if (opts) { - mongoose.connect(db, opts, function (err) { - afterConnect(_this, err, cb); - }); + opts.useNewUrlParser = true; } else { - mongoose.connect(db, function (err) { - afterConnect(_this, err, cb); - }); + opts = { + useNewUrlParser: true + }; } + + mongoose.connect(db, opts, function (err) { + afterConnect(_this, err, cb); + }); } }; @@ -133,7 +135,7 @@ Seeder.prototype.clearModels = function(models, cb) { // Clear each model async.each(modelNames, function(modelName, done) { var Model = mongoose.model(modelName); - Model.remove({}, function(err) { + Model.deleteMany({}, function(err) { if (err) { console.error(chalk.red('Error: ' + err.message)); return; diff --git a/package.json b/package.json index b8e1f00..748c96d 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Seed data population for Mongoose", "main": "index.js", "scripts": { - "test": "mocha test/**/*.js" + "test": "mocha --exit test/**/*.js" }, "repository": { "type": "git", @@ -28,14 +28,14 @@ }, "homepage": "https://github.com/seanemmer/mongoose-seed#readme", "dependencies": { - "async": "~1.2.0", - "chalk": "~1.0.0", - "lodash": "~4.17.10", - "path": "~0.11.14" + "async": "~2.6.1", + "chalk": "~2.4.2", + "lodash": "~4.17.11", + "path": "~0.12.7" }, "devDependencies": { - "chai": "^3.5.0", - "mocha": "^3.0.0", - "mongoose": "^4.5.8" + "chai": "^4.2.0", + "mocha": "^5.2.0", + "mongoose": "^5.4.8" } }