From 3564f4cbfe12f25926f9bf1c02a3ab95e0e439c5 Mon Sep 17 00:00:00 2001 From: Fortune Date: Wed, 14 Aug 2019 22:29:14 +0100 Subject: [PATCH] Fix deprecation warnings for mongoose connection options --- index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 3238d8bf..ecfd044c 100644 --- a/index.js +++ b/index.js @@ -15,7 +15,13 @@ mongoose.Promise = Promise; // connect to mongo db const mongoUri = config.mongo.host; -mongoose.connect(mongoUri, { server: { socketOptions: { keepAlive: 1 } } }); +mongoose.connect(mongoUri, { + keepAlive: true, + useNewUrlParser: true, + useCreateIndex: true, + useFindAndModify: false +}); + mongoose.connection.on('error', () => { throw new Error(`unable to connect to database: ${mongoUri}`); });