From 6feab9ef6853b73184dffbe69657ff5c1dcf4558 Mon Sep 17 00:00:00 2001 From: rxbn_ Date: Fri, 30 Oct 2020 23:19:48 +0100 Subject: [PATCH] db - fix deprecation warnings and index timestamps --- bin/database/models.js | 2 +- bin/database/module.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/database/models.js b/bin/database/models.js index 0145af2..da4e5d8 100644 --- a/bin/database/models.js +++ b/bin/database/models.js @@ -86,7 +86,7 @@ models.authCode = new Schema({ applicationId: Schema.Types.ObjectId, // reference to application userId: Schema.Types.ObjectId, // reference to user token: String, // generated token, only usable in combination with userId and applicationId - timestamp: { type: Date, default: Date.now } + timestamp: { type: Date, default: Date.now, index: {unique: true, expires: '5m'} } }); module.exports = (con) => { diff --git a/bin/database/module.js b/bin/database/module.js index 2ac7c75..505e6c1 100644 --- a/bin/database/module.js +++ b/bin/database/module.js @@ -33,7 +33,8 @@ methods.connect = async () => { mongoose.connect(cfg.mongoose.uri, { useNewUrlParser: true, useUnifiedTopology: true, - useFindAndModify: false + useFindAndModify: false, + useCreateIndex: true });