1
0
mirror of https://github.com/tcgdex/cards-database.git synced 2025-06-28 23:09:18 +00:00

fix: sets not working when fetching with name

This commit is contained in:
2024-09-26 00:31:10 +02:00
parent 4700618047
commit b9dae445b1
5 changed files with 44 additions and 8 deletions

View File

@ -251,6 +251,7 @@ server
*/
.get('/:lang/:endpoint/:id/:subid', (req: CustomRequest, res) => {
let { id, lang, endpoint, subid } = req.params
console.log(req.params)
if (subid.endsWith('.json')) {
subid = subid.replace('.json', '')
@ -270,7 +271,7 @@ server
// allow the dev to use a non prefixed value like `10` instead of `010` for newer sets
result = Card
// @ts-expect-error normal behavior until the filtering is more fiable
.findOne(lang, { localId: { $or: [subid.padStart(3, '0'), subid]}, 'set.id': id })?.full()
.findOne(lang, { localId: { $or: [subid.padStart(3, '0'), subid]}, $or: [{ 'set.id': id }, { 'set.name': id }] })?.full()
break
}
if (!result) {