bitcointranscripts / transcription-review-backend

7 stars 11 forks source link

fix: offset calculation in getAllTransactions #297

Closed Extheoisah closed 1 month ago

Extheoisah commented 1 month ago

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: