mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
完善设置
This commit is contained in:
1 parent
fc0d9873a2
commit
7edb29d7b8
43 files changed
+219
-184
No files matched your search
@@ -1,6 +1,6 @@
|
||||
const { ValidationError } = require('../error');
|
||||
|
||||
module.exports = async function paginate(cursor, page, pageSize) {
|
||||
async function paginate(cursor, page, pageSize) {
|
||||
if (page <= 0) throw new ValidationError('page');
|
||||
const [count, pageDocs] = await Promise.all([
|
||||
cursor.count(),
|
||||
@@ -8,4 +8,6 @@ module.exports = async function paginate(cursor, page, pageSize) {
|
||||
]);
|
||||
const numPages = Math.floor((count + pageSize - 1) / pageSize);
|
||||
return [pageDocs, numPages, count];
|
||||
};
|
||||
}
|
||||
|
||||
global.Hydro.lib.paginate = module.exports = paginate;
|
||||
Reference in new issue
Block a user