mirror of
https://github.com/jcreek/LivingDexTracker.git
synced 2026-07-13 11:03:44 +00:00
fix(*): Fix bug returning 0 for document counts when filtering by region and game
This commit is contained in:
@@ -84,17 +84,16 @@ class CombinedDataRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (game.length > 0) {
|
if (game.length > 0) {
|
||||||
// Check if gamesToCatchIn is not already defined in filter
|
filter['gamesToCatchIn'] = { $in: [game] };
|
||||||
if (!filter['gamesToCatchIn']) {
|
|
||||||
filter['gamesToCatchIn'] = [];
|
|
||||||
}
|
|
||||||
// Add the game to the filter if it's not already included
|
|
||||||
if (!filter['gamesToCatchIn'].includes(game)) {
|
|
||||||
filter['gamesToCatchIn'].push(game);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return PokedexEntryModel.countDocuments(filter).exec();
|
try {
|
||||||
|
const count = await PokedexEntryModel.countDocuments(filter).exec();
|
||||||
|
return count;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error counting documents:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user