Skip to content

Commit 59b5040

Browse files
committed
implement exclusive filter by state
1 parent 6b104e5 commit 59b5040

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

src/modules/games/games.controller.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
import { InjectRepository } from "@nestjs/typeorm";
2323
import { Response } from "express";
2424
import {
25+
FilterOperator,
2526
Paginate,
2627
PaginateQuery,
2728
Paginated,
@@ -31,6 +32,7 @@ import {
3132
import { Repository } from "typeorm";
3233

3334
import { isArray } from "lodash";
35+
import { FilterSuffix } from "nestjs-paginate/lib/filter";
3436
import configuration from "../../configuration";
3537
import { MinimumRole } from "../../decorators/minimum-role.decorator";
3638
import { PaginateQueryOptions } from "../../decorators/pagination.decorator";
@@ -101,7 +103,7 @@ export class GamesController {
101103
const rawFilterValue = progressStateFilter.split(":").pop();
102104
query.filter["progresses.state"] = [
103105
"$null",
104-
`$or:$in:${rawFilterValue}`,
106+
`$or:$eq:${rawFilterValue}`,
105107
];
106108
}
107109

@@ -110,7 +112,6 @@ export class GamesController {
110112
query.filter["progresses.user.id"] = [
111113
"$null",
112114
`$or:$not:${rawFilterValue}`,
113-
`$or:$eq:${rawFilterValue}`,
114115
];
115116
}
116117
}
@@ -173,8 +174,16 @@ export class GamesController {
173174
"metadata.genres.name": true,
174175
"metadata.tags.name": true,
175176
"metadata.age_rating": true,
176-
"progresses.state": true,
177-
"progresses.user.id": true,
177+
"progresses.state": [
178+
FilterOperator.EQ,
179+
FilterOperator.NULL,
180+
FilterSuffix.NOT,
181+
],
182+
"progresses.user.id": [
183+
FilterOperator.EQ,
184+
FilterOperator.NULL,
185+
FilterSuffix.NOT,
186+
],
178187
},
179188
withDeleted: false,
180189
});

0 commit comments

Comments
 (0)