From da7a5fdde2fb26bbe78dd588da391bc7ff25ad8f Mon Sep 17 00:00:00 2001 From: Roger Hernandez Date: Thu, 23 Jul 2020 16:11:40 +0200 Subject: [PATCH] Code detail improvement --- rest/src/plugins/namespace/NamespaceDb.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/rest/src/plugins/namespace/NamespaceDb.js b/rest/src/plugins/namespace/NamespaceDb.js index 2e6798e20..1338aae5e 100644 --- a/rest/src/plugins/namespace/NamespaceDb.js +++ b/rest/src/plugins/namespace/NamespaceDb.js @@ -20,9 +20,6 @@ const { convertToLong, buildOffsetCondition } = require('../../db/dbUtils'); const catapult = require('catapult-sdk'); -const MongoDb = require('mongodb'); - -const { Long } = MongoDb; const createActiveConditions = () => { const conditions = { $and: [{ 'meta.active': true }] }; @@ -62,7 +59,7 @@ class NamespaceDb { conditions.push({ 'namespace.alias.type': aliasType }); if (undefined !== level0) - conditions.push({ 'namespace.level0': new Long(level0[0], level0[1]) }); + conditions.push({ 'namespace.level0': convertToLong(level0) }); if (undefined !== ownerAddress) conditions.push({ 'namespace.ownerAddress': Buffer.from(ownerAddress) }); @@ -83,12 +80,11 @@ class NamespaceDb { * @returns {Promise.} Namespace. */ namespaceById(id) { - const namespaceId = new Long(id[0], id[1]); const conditions = { $or: [] }; for (let level = 0; 3 > level; ++level) { const conjunction = createActiveConditions(); - conjunction.$and.push({ [`namespace.level${level}`]: namespaceId }); + conjunction.$and.push({ [`namespace.level${level}`]: convertToLong(id) }); conjunction.$and.push({ 'namespace.depth': level + 1 }); conditions.$or.push(conjunction);