diff --git a/lib/datastore.js b/lib/datastore.js index 740abf8..92fed60 100755 --- a/lib/datastore.js +++ b/lib/datastore.js @@ -668,7 +668,7 @@ class Datastore extends EventEmitter { * @private */ async _getCandidatesAsync (query, dontExpireStaleDocs = false) { - const validDocs = [] + let validDocs = [] // STEP 1: get candidates list by checking indexes from most to least frequent usecase const docs = this._getRawCandidates(query) @@ -684,7 +684,7 @@ class Datastore extends EventEmitter { for (const _id of expiredDocsIds) { await this._removeAsync({ _id }, {}) } - } else validDocs.push(...docs) + } else validDocs = docs return validDocs }