bug fixes

This commit is contained in:
undefined committed 2024-10-16 00:25:58 +08:00
1 parent b777afc1cc
commit 0ff088a677
3 files changed
+8 -7

No files matched your search

+2 -2
View File
@@ -124,12 +124,12 @@ class MongoService {
return [pageDocs, numPages, count];
}
async ranked<T extends Record<string, any>>(cursor: FindCursor<T>, equ: (a: T, b: T) => boolean): Promise<[number, T][]> {
async ranked<T extends Record<string, any>>(cursor: T[] | FindCursor<T>, equ: (a: T, b: T) => boolean): Promise<[number, T][]> {
let last = null;
let r = 0;
let count = 0;
const results = [];
const docs = await cursor.toArray();
const docs = cursor instanceof Array ? cursor : await cursor.toArray();
for (const doc of docs) {
if ((doc as any).unrank) {
results.push([0, doc]);