Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(core-database-postgres): add findByHeight to avoid confusion with the misleading findByHeights #2338

Merged
merged 7 commits into from
Mar 29, 2019
Prev Previous commit
Merge remote-tracking branch 'origin/develop' into refactor/misleadin…
…g-height-methds
  • Loading branch information
spkjp committed Mar 29, 2019
commit 8316fa1c54ffafc9fcadc0cd2bbfdb23b3497d0c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class BlocksBusinessRepository implements Database.IBlocksBusinessReposit
}

public async findAllByGenerator(generatorPublicKey: string, paginate: Database.SearchPaginate) {
return this.findAll({ ...{ generatorPublicKey }, ...paginate });
return this.findAll({ generatorPublicKey, ...paginate });
}

public async findLastByPublicKey(generatorPublicKey: string) {
Expand All @@ -19,13 +19,23 @@ export class BlocksBusinessRepository implements Database.IBlocksBusinessReposit
}

public async findByHeight(height: number) {
return this.findAll({ ...{ height } });
return this.findAll({ height });
}

public async findById(id: string) {
return this.databaseServiceProvider().connection.blocksRepository.findById(id);
}

public async findByIdOrHeight(idOrHeight) {
try {
const { rows } = await this.findByHeight(idOrHeight);

return rows[0];
} catch (error) {
return this.findById(idOrHeight);
}
}

public async search(params: Database.IParameters) {
return this.databaseServiceProvider().connection.blocksRepository.search(this.parseSearchParams(params));
}
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.