From 9c08e51d313812ec60affaeb18e2689fd2a70047 Mon Sep 17 00:00:00 2001 From: Fachba Date: Tue, 21 Oct 2025 20:05:15 +0700 Subject: [PATCH] fixing pagination --- db/brand.db.js | 2 +- db/device.db.js | 2 +- db/roles.db.js | 2 +- db/schedule.db.js | 2 +- db/shift.db.js | 2 +- db/status.db.js | 2 +- db/sub_section.db.js | 2 +- db/tags.db.js | 2 +- db/unit.db.js | 2 +- db/user.db.js | 2 +- db/user_schedule.db.js | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/db/brand.db.js b/db/brand.db.js index 6182e1a..3385e8f 100644 --- a/db/brand.db.js +++ b/db/brand.db.js @@ -34,7 +34,7 @@ const getAllBrandsDb = async (searchParams = {}) => { ${whereConditions.length > 0 ? ` AND ${whereConditions.join(" AND ")}` : ""} ${whereOrConditions ? whereOrConditions : ""} ORDER BY b.brand_id ASC - ${searchParams.limit ? `OFFSET $2 ROWS FETCH NEXT $1 ROWS ONLY` : ""}; + ${searchParams.limit ? `OFFSET $2 * $1 ROWS FETCH NEXT $1 ROWS ONLY` : ''} `; const result = await pool.query(queryText, queryParams); diff --git a/db/device.db.js b/db/device.db.js index c28d9a0..b2000c1 100644 --- a/db/device.db.js +++ b/db/device.db.js @@ -50,7 +50,7 @@ const getAllDevicesDb = async (searchParams = {}) => { ${whereConditions.length > 0 ? `AND ${whereConditions.join(' AND ')}` : ''} ${whereOrConditions ? whereOrConditions : ''} ORDER BY a.device_id ASC - ${searchParams.limit ? `OFFSET $2 ROWS FETCH NEXT $1 ROWS ONLY` : ''}; + ${searchParams.limit ? `OFFSET $2 * $1 ROWS FETCH NEXT $1 ROWS ONLY` : ''} `; const result = await pool.query(queryText, queryParams); diff --git a/db/roles.db.js b/db/roles.db.js index 56c42c5..17d20c5 100644 --- a/db/roles.db.js +++ b/db/roles.db.js @@ -35,7 +35,7 @@ const getAllRolesDb = async (searchParams = {}) => { ${whereConditions.length > 0 ? ` AND ${whereConditions.join(" AND ")}` : ""} ${whereOrConditions ? ` ${whereOrConditions}` : ""} ORDER BY a.role_id ASC - ${searchParams.limit ? `OFFSET $2 ROWS FETCH NEXT $1 ROWS ONLY` : ""} + ${searchParams.limit ? `OFFSET $2 * $1 ROWS FETCH NEXT $1 ROWS ONLY` : ''} `; const result = await pool.query(queryText, queryParams); diff --git a/db/schedule.db.js b/db/schedule.db.js index d3a598c..807a085 100644 --- a/db/schedule.db.js +++ b/db/schedule.db.js @@ -36,7 +36,7 @@ const getAllScheduleDb = async (searchParams = {}) => { ${whereConditions.length > 0 ? ` AND ${whereConditions.join(" AND ")}` : ""} ${whereOrConditions ? ` ${whereOrConditions}` : ""} ORDER BY a.schedule_id ASC - ${searchParams.limit ? `OFFSET $2 ROWS FETCH NEXT $1 ROWS ONLY` : ""} + ${searchParams.limit ? `OFFSET $2 * $1 ROWS FETCH NEXT $1 ROWS ONLY` : ''} `; const result = await pool.query(queryText, queryParams); diff --git a/db/shift.db.js b/db/shift.db.js index 4dc4192..71490a7 100644 --- a/db/shift.db.js +++ b/db/shift.db.js @@ -36,7 +36,7 @@ const getAllShiftDb = async (searchParams = {}) => { ${whereConditions.length > 0 ? ` AND ${whereConditions.join(" AND ")}` : ""} ${whereOrConditions ? ` ${whereOrConditions}` : ""} ORDER BY a.shift_id ASC - ${searchParams.limit ? `OFFSET $2 ROWS FETCH NEXT $1 ROWS ONLY` : ""} + ${searchParams.limit ? `OFFSET $2 * $1 ROWS FETCH NEXT $1 ROWS ONLY` : ''} `; const result = await pool.query(queryText, queryParams); diff --git a/db/status.db.js b/db/status.db.js index 37cbd2a..f5cd6d3 100644 --- a/db/status.db.js +++ b/db/status.db.js @@ -39,7 +39,7 @@ const getAllStatusDb = async (searchParams = {}) => { ${whereConditions.length > 0 ? `AND ${whereConditions.join(' AND ')}` : ''} ${whereOrConditions ? whereOrConditions : ''} ORDER BY a.status_id ASC - ${searchParams.limit ? `OFFSET $2 ROWS FETCH NEXT $1 ROWS ONLY` : ''}; + ${searchParams.limit ? `OFFSET $2 * $1 ROWS FETCH NEXT $1 ROWS ONLY` : ''} `; const result = await pool.query(queryText, queryParams); diff --git a/db/sub_section.db.js b/db/sub_section.db.js index e4358d7..8d40e90 100644 --- a/db/sub_section.db.js +++ b/db/sub_section.db.js @@ -37,7 +37,7 @@ const getAllSubSectionsDb = async (searchParams = {}) => { ${whereConditions.length > 0 ? ` AND ${whereConditions.join(" AND ")}` : ""} ${whereOrConditions ? whereOrConditions : ""} ORDER BY a.sub_section_id ASC - ${searchParams.limit ? `OFFSET $2 ROWS FETCH NEXT $1 ROWS ONLY` : ""}; + ${searchParams.limit ? `OFFSET $2 * $1 ROWS FETCH NEXT $1 ROWS ONLY` : ''} `; const result = await pool.query(queryText, queryParams); diff --git a/db/tags.db.js b/db/tags.db.js index 41b61c9..9f47031 100644 --- a/db/tags.db.js +++ b/db/tags.db.js @@ -62,7 +62,7 @@ const getAllTagsDb = async (searchParams = {}) => { ${whereConditions.length > 0 ? ` AND ${whereConditions.join(" AND ")}` : ""} ${whereOrConditions ? ` ${whereOrConditions}` : ""} ORDER BY a.tag_id ASC - ${searchParams.limit ? `OFFSET $2 ROWS FETCH NEXT $1 ROWS ONLY` : ""} + ${searchParams.limit ? `OFFSET $2 * $1 ROWS FETCH NEXT $1 ROWS ONLY` : ''} `; const result = await pool.query(queryText, queryParams); diff --git a/db/unit.db.js b/db/unit.db.js index ad96fb4..3649fe2 100644 --- a/db/unit.db.js +++ b/db/unit.db.js @@ -42,7 +42,7 @@ const getAllUnitsDb = async (searchParams = {}) => { ${whereConditions.length > 0 ? `AND ${whereConditions.join(" AND ")}` : ""} ${whereOrConditions ? whereOrConditions : ""} ORDER BY a.unit_id ASC - ${searchParams.limit ? `OFFSET $2 ROWS FETCH NEXT $1 ROWS ONLY` : ""}; + ${searchParams.limit ? `OFFSET $2 * $1 ROWS FETCH NEXT $1 ROWS ONLY` : ''} `; const result = await pool.query(queryText, queryParams); diff --git a/db/user.db.js b/db/user.db.js index c8772b6..83620cf 100644 --- a/db/user.db.js +++ b/db/user.db.js @@ -53,7 +53,7 @@ const getAllUsersDb = async (searchParams = {}) => { ${whereConditions.length > 0 ? ` AND ${whereConditions.join(' AND ')}` : ''} ${whereOrConditions ? whereOrConditions : ''} ORDER BY u.user_id ASC - ${searchParams.limit ? `OFFSET $2 ROWS FETCH NEXT $1 ROWS ONLY` : ''}; + ${searchParams.limit ? `OFFSET $2 * $1 ROWS FETCH NEXT $1 ROWS ONLY` : ''} `; const result = await pool.query(queryText, queryParams); diff --git a/db/user_schedule.db.js b/db/user_schedule.db.js index 68822ad..525fd61 100644 --- a/db/user_schedule.db.js +++ b/db/user_schedule.db.js @@ -44,7 +44,7 @@ const getAllUserScheduleDb = async (searchParams = {}) => { ${whereConditions.length > 0 ? ` AND ${whereConditions.join(" AND ")}` : ""} ${whereOrConditions ? ` ${whereOrConditions}` : ""} ORDER BY a.user_schedule_id ASC - ${searchParams.limit ? `OFFSET $2 ROWS FETCH NEXT $1 ROWS ONLY` : ""} + ${searchParams.limit ? `OFFSET $2 * $1 ROWS FETCH NEXT $1 ROWS ONLY` : ''} `; const result = await pool.query(queryText, queryParams);