const pagesize = 10; const page = Number(context.query.page) || 1; const offset = (page - 1) * pagesize; const db = an49(); const dt1 = db<ITbtable>('table'); const [{ size }] = await dt1.count('*', { as: 'size' }); const total = Number(size); let count = parseInt(`${total / pagesize}`); const dt2 = db<ITbtable>('table'); const data = await dt2.select('*').limit(pagesize).offset(offset).orderBy('sort', 'desc'); if (total % pagesize) { ++count; }