core: fix db pagination filter

This commit is contained in:
undefined committed 2025-03-22 10:59:06 +08:00
1 parent 3a776c3010
commit 917ed3d555
1 file changed
+2 -6
+2 -6
View File
@@ -144,12 +144,8 @@ export class MongoService extends Service {
cursor: FindCursor<T>, page: number, pageSize: number,
): Promise<[docs: T[], numPages: number, count: number]> {
if (page <= 0) throw new ValidationError('page');
let filter = {};
for (const key of Object.getOwnPropertySymbols(cursor)) {
if (key.toString() !== 'Symbol(filter)') continue;
filter = cursor[key];
break;
}
// this is for mongodb driver v6
const filter = (cursor as any).cursorFilter;
const coll = this.db.collection(cursor.namespace.collection as any);
const [count, pageDocs] = await Promise.all([
Object.keys(filter).length ? coll.count(filter) : coll.countDocuments(filter),