mirror of
https://github.com/IT4Change/gradido.git
synced 2026-01-15 01:14:35 +00:00
default values for filters
This commit is contained in:
parent
d0b2a28ae2
commit
d1770ccb1a
@ -2,12 +2,12 @@ import { ArgsType, Field } from 'type-graphql'
|
||||
|
||||
@ArgsType()
|
||||
export default class TransactionLinkFilters {
|
||||
@Field(() => Boolean, { nullable: true })
|
||||
@Field(() => Boolean, { nullable: true, defaultValue: true })
|
||||
withDeleted?: boolean
|
||||
|
||||
@Field(() => Boolean, { nullable: true })
|
||||
@Field(() => Boolean, { nullable: true, defaultValue: true })
|
||||
withExpired?: boolean
|
||||
|
||||
@Field(() => Boolean, { nullable: true })
|
||||
@Field(() => Boolean, { nullable: true, defaultValue: true })
|
||||
withRedeemed?: boolean
|
||||
}
|
||||
|
||||
@ -381,7 +381,7 @@ export class AdminResolver {
|
||||
@Args()
|
||||
{ currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated,
|
||||
@Args()
|
||||
{ withDeleted = true, withExpired = true, withRedeemed = true }: TransactionLinkFilters,
|
||||
filters: TransactionLinkFilters,
|
||||
@Arg('userId', () => Int) userId: number,
|
||||
): Promise<TransactionLink[]> {
|
||||
const user = await dbUser.findOneOrFail({ id: userId })
|
||||
@ -392,11 +392,11 @@ export class AdminResolver {
|
||||
} = {
|
||||
userId,
|
||||
}
|
||||
if (!withRedeemed) where.redeemedBy = null
|
||||
if (!withExpired) where.validUntil = MoreThan(new Date())
|
||||
if (!filters.withRedeemed) where.redeemedBy = null
|
||||
if (!filters.withExpired) where.validUntil = MoreThan(new Date())
|
||||
const transactionLinks = await dbTransactionLink.find({
|
||||
where,
|
||||
withDeleted,
|
||||
withDeleted: filters.withDeleted,
|
||||
order: {
|
||||
createdAt: order,
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user