Skip to content
This repository has been archived by the owner on Jun 10, 2022. It is now read-only.

Commit

Permalink
Code detail improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
Vektrat authored Jul 23, 2020
1 parent 33fab39 commit da7a5fd
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions rest/src/plugins/namespace/NamespaceDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }] };
Expand Down Expand Up @@ -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) });
Expand All @@ -83,12 +80,11 @@ class NamespaceDb {
* @returns {Promise.<object>} 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);
Expand Down

0 comments on commit da7a5fd

Please sign in to comment.