core: performance: userCache&scoreboard.pagination

This commit is contained in:
undefined committed 2021-05-02 18:44:15 +08:00
1 parent 0454acdbf9
commit 0d7c53b927
12 files changed
+244 -166

No files matched your search

+3 -3
View File
@@ -1,9 +1,9 @@
import { Cursor } from 'mongodb';
import { ValidationError } from '../error';
async function paginate(
cursor: Cursor, page: number, pageSize: number,
): Promise<[any[]/* docs */, number/* numPages */, number/* count */]> {
async function paginate<T>(
cursor: Cursor<T>, page: number, pageSize: number,
): Promise<[docs: T[], numPages: number, count: number]> {
if (page <= 0) throw new ValidationError('page');
const [count, pageDocs] = await Promise.all([
cursor.count(),