Skip to content

Commit

Permalink
Handle zero balances on paging
Browse files Browse the repository at this point in the history
  • Loading branch information
charlie-wasp committed Apr 15, 2019
1 parent dca3ddb commit f1eea0d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/repo/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,17 @@ export default class AssetsRepo {
queryBuilder.order("accountid");

if (cursor) {
const [, , balance] = Buffer.from(cursor, "base64")
const [accountId, , balance] = Buffer.from(cursor, "base64")
.toString()
.split("_");

queryBuilder.where("accountid != ?", accountId);

if (paging.after) {
queryBuilder.where("balance < ?", balance);
// <= and >= allow to handle zero balances
queryBuilder.where("balance <= ?", balance);
} else {
queryBuilder.where("balance > ?", balance);
queryBuilder.where("balance >= ?", balance);
}
}

Expand Down

0 comments on commit f1eea0d

Please sign in to comment.