page.js 325 B

12345678910
  1. import {sqlHandle} from "./db.js";
  2. const PageResult = async (sql, pageNum, pageSize, Entity) => {
  3. const result = await sqlHandle(sql)
  4. return {
  5. data: result.slice((pageNum - 1) * pageSize, pageNum * pageSize).map(v => Entity ? new Entity(v) : v),
  6. total: result.length
  7. }
  8. }
  9. export default PageResult