feat: improve schedule querying with flexible filtering and pagination

- Updated ScheduleSchema to enhance the querying logic for schedules by allowing dynamic filtering, ordering, and pagination.
- Replaced static customerId filtering with flexible arguments for filtering, ordering, skipping, and taking results.
- This change increases the versatility of schedule retrieval based on user-defined criteria.
This commit is contained in:
2024-12-03 21:10:14 +07:00
parent 6f5db20324
commit 951d61f3ac

View File

@@ -266,9 +266,10 @@ export class ScheduleSchema extends PothosSchema {
if (ctx.http.me.role === Role.CUSTOMER) { if (ctx.http.me.role === Role.CUSTOMER) {
const schedules = await this.prisma.schedule.findMany({ const schedules = await this.prisma.schedule.findMany({
...query, ...query,
where: { orderBy: args.orderBy ?? undefined,
customerId: ctx.http.me.id, skip: args.skip ?? undefined,
}, take: args.take ?? undefined,
where: args.filter ?? undefined,
}) })
return schedules return schedules
} }