The offset calculation in the getAllTransactions function was incorrect, resulting in incorrect pagination of transactions from the db.
Using const offset: number = page * limit; doesn't work correctly for pagination because it does not properly account for the zero-based index of pages. Pagination typically requires starting at offset 0 for the first page, offset 1 for the second page, and so on.
The correct offset calculation for pagination is const offset = (page - 1) * limit;. This ensures that:
The offset calculation in the
getAllTransactions
function was incorrect, resulting in incorrect pagination of transactions from the db.Using
const offset: number = page * limit;
doesn't work correctly for pagination because it does not properly account for the zero-based index of pages. Pagination typically requires starting at offset 0 for the first page, offset 1 for the second page, and so on.The correct offset calculation for pagination is
const offset = (page - 1) * limit;
. This ensures that:limit
2 * limit
and so on.