From 5f7bc1244d7943c263057b4d73ffb3282d63f685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Rebours?= Date: Thu, 21 Oct 2021 08:56:17 +0200 Subject: [PATCH] WIP: linting --- lib/datastore.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/datastore.js b/lib/datastore.js index 9dd255c..c1788bd 100755 --- a/lib/datastore.js +++ b/lib/datastore.js @@ -1,6 +1,5 @@ const { EventEmitter } = require('events') const { callbackify } = require('util') -const async = require('async') const Cursor = require('./cursor.js') const customUtils = require('./customUtils.js') const Executor = require('./executor.js') @@ -315,21 +314,21 @@ class Datastore extends EventEmitter { // STEP 1: get candidates list by checking indexes from most to least frequent usecase const docs = _getCandidates(query) // STEP 2: remove all expired documents - if (!dontExpireStaleDocs) { + if (!dontExpireStaleDocs) { const expiredDocsIds = [] const ttlIndexesFieldNames = Object.keys(this.ttlIndexes) docs.forEach(doc => { - if (ttlIndexesFieldNames.every(i => !(doc[i] !== undefined && isDate(doc[i]) && Date.now() > doc[i].getTime() + this.ttlIndexes[i] * 1000))) validDocs.push(doc) + if (ttlIndexesFieldNames.every(i => !(doc[i] !== undefined && isDate(doc[i]) && Date.now() > doc[i].getTime() + this.ttlIndexes[i] * 1000))) validDocs.push(doc) else expiredDocsIds.push(doc._id) }) - for (const _id of expiredDocsIds) { - await new Promise((resolve, reject) => { - this._remove({ _id: _id }, {}, err => { - if (err) return reject(err) - return resolve() - }) + for (const _id of expiredDocsIds) { + await new Promise((resolve, reject) => { + this._remove({ _id: _id }, {}, err => { + if (err) return reject(err) + return resolve() }) + }) } } else validDocs.push(...docs) return validDocs