mirror of
https://github.com/jwinterm/nodejs-pool.git
synced 2026-10-17 05:21:27 +02:00
fix mysql query for pagination. page number should be multiply by limit to get the offset
This commit is contained in:
+2
-2
@@ -461,7 +461,7 @@ app.get('/pool/payments', function (req, res) {
|
||||
let limit = typeof(req.query.limit) !== 'undefined' ? Number(req.query.limit) : 10;
|
||||
let page = typeof(req.query.page) !== 'undefined' ? Number(req.query.page) : 0;
|
||||
let query = "SELECT * FROM transactions ORDER BY id DESC LIMIT ? OFFSET ?";
|
||||
global.mysql.query(query, [limit, page]).then(function (rows) {
|
||||
global.mysql.query(query, [limit, page * limit]).then(function (rows) {
|
||||
if (rows.length === 0) {
|
||||
return res.json([]);
|
||||
}
|
||||
@@ -514,7 +514,7 @@ app.get('/miner/:address/payments', function (req, res) {
|
||||
"payments WHERE payment_address = ? AND payment_id IS ? ORDER BY paid_time DESC LIMIT ? OFFSET ?";
|
||||
}
|
||||
let response = [];
|
||||
global.mysql.query(query, [address, payment_id, limit, page]).then(function (rows) {
|
||||
global.mysql.query(query, [address, payment_id, limit, page * limit]).then(function (rows) {
|
||||
if (rows.length === 0) {
|
||||
return res.json(response);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user