refactor schema to match database schema

This commit is contained in:
2024-10-27 13:12:24 +07:00
parent 8d46676a37
commit 9e0e97a560
14 changed files with 73 additions and 63 deletions

View File

@@ -28,7 +28,7 @@ export class CategorySchema extends PothosSchema {
name: t.exposeString('name', { name: t.exposeString('name', {
description: 'The name of the category.', description: 'The name of the category.',
}), }),
subCategory: t.relation('SubCategory', { subCategory: t.relation('subCategory', {
description: 'The subcategory of the category.', description: 'The subcategory of the category.',
}), }),
}), }),

View File

@@ -67,10 +67,10 @@ export class CenterSchema extends PothosSchema {
chatRoom: t.relation('chatRoom', { chatRoom: t.relation('chatRoom', {
description: 'The chat room associated with the center.', description: 'The chat room associated with the center.',
}), }),
centerStaff: t.relation('CenterStaff', { centerStaff: t.relation('centerStaff', {
description: 'The staff members of the center.', description: 'The staff members of the center.',
}), }),
resume: t.relation('Resume', { resume: t.relation('resume', {
description: 'The resume of the center.', description: 'The resume of the center.',
}), }),
centerStatus: t.expose('centerStatus', { centerStatus: t.expose('centerStatus', {
@@ -123,7 +123,7 @@ export class CenterSchema extends PothosSchema {
resolve: async (query, root, args, ctx, info) => { resolve: async (query, root, args, ctx, info) => {
return await this.prisma.center.findFirst({ return await this.prisma.center.findFirst({
where: { where: {
CenterStaff: { centerStaff: {
some: { some: {
staffId: args.userId, staffId: args.userId,
}, },

View File

@@ -37,7 +37,7 @@ export class CenterStaffSchema extends PothosSchema {
createdWorkshop: t.relation('createdWorkshop', { createdWorkshop: t.relation('createdWorkshop', {
description: 'The workshops created by the center staff.', description: 'The workshops created by the center staff.',
}), }),
ManagedService: t.relation('ManagedService', { managedService: t.relation('managedService', {
description: 'The managed services of the center staff.', description: 'The managed services of the center staff.',
}), }),
}), }),

View File

@@ -53,7 +53,7 @@ export class OrderSchema extends PothosSchema {
user: t.relation('user', { user: t.relation('user', {
description: 'The user who made the order.', description: 'The user who made the order.',
}), }),
payment: t.relation('Payment', { payment: t.relation('payment', {
description: 'The payment for the order.', description: 'The payment for the order.',
}), }),
service: t.relation('service', { service: t.relation('service', {

View File

@@ -42,7 +42,7 @@ export class PaymentSchema extends PothosSchema {
type: 'DateTime', type: 'DateTime',
description: 'The date and time the payment was updated.', description: 'The date and time the payment was updated.',
}), }),
order: t.relation('Order', { order: t.relation('order', {
description: 'The order for the payment.', description: 'The order for the payment.',
}), }),
}), }),

View File

@@ -51,7 +51,7 @@ export class ResumeSchema extends PothosSchema {
center: t.relation('center', { center: t.relation('center', {
description: 'The center for the resume.', description: 'The center for the resume.',
}), }),
resumeFile: t.relation('ResumeFile', { resumeFile: t.relation('resumeFile', {
description: 'The resume file for the resume.', description: 'The resume file for the resume.',
}), }),
}), }),
@@ -224,7 +224,7 @@ export class ResumeSchema extends PothosSchema {
create: { create: {
userId, userId,
centerId, centerId,
ResumeFile: { resumeFile: {
create: { create: {
fileUrl: fileUrl ?? '', fileUrl: fileUrl ?? '',
type: mimetype, type: mimetype,
@@ -233,7 +233,7 @@ export class ResumeSchema extends PothosSchema {
}, },
}, },
update: { update: {
ResumeFile: { resumeFile: {
create: { create: {
fileUrl: fileUrl ?? '', fileUrl: fileUrl ?? '',
type: mimetype, type: mimetype,

View File

@@ -30,11 +30,11 @@ export class ScheduleSchema extends PothosSchema {
description: 'The ID of the managed service the schedule belongs to.', description: 'The ID of the managed service the schedule belongs to.',
nullable: false, nullable: false,
}), }),
scheduleStart: t.expose('ScheduleStart', { scheduleStart: t.expose('scheduleStart', {
type: 'DateTime', type: 'DateTime',
nullable: false, nullable: false,
}), }),
scheduleEnd: t.expose('ScheduleEnd', { scheduleEnd: t.expose('scheduleEnd', {
type: 'DateTime', type: 'DateTime',
nullable: false, nullable: false,
}), }),
@@ -45,7 +45,7 @@ export class ScheduleSchema extends PothosSchema {
type: ScheduleStatus, type: ScheduleStatus,
nullable: false, nullable: false,
}), }),
managedService: t.relation('ManagedService', { managedService: t.relation('managedService', {
description: 'The managed service the schedule belongs to.', description: 'The managed service the schedule belongs to.',
nullable: false, nullable: false,
}), }),
@@ -72,7 +72,7 @@ export class ScheduleSchema extends PothosSchema {
type: 'DateTime', type: 'DateTime',
nullable: false, nullable: false,
}), }),
schedule: t.relation('Schedule', { schedule: t.relation('schedule', {
description: 'The schedule the schedule date belongs to.', description: 'The schedule the schedule date belongs to.',
}), }),
}), }),

View File

@@ -92,7 +92,7 @@ export class ServiceSchema extends PothosSchema {
user: t.relation('user', { user: t.relation('user', {
description: 'The user who requested the service.', description: 'The user who requested the service.',
}), }),
managedService: t.relation('ManagedService', { managedService: t.relation('managedService', {
description: 'The managed service for the service.', description: 'The managed service for the service.',
}), }),
}), }),

View File

@@ -28,7 +28,7 @@ export class ServiceAndCategorySchema extends PothosSchema {
service: t.relation('service', { service: t.relation('service', {
description: 'The service for the service and category.', description: 'The service for the service and category.',
}), }),
subCategory: t.relation('SubCategory', { subCategory: t.relation('subCategory', {
description: 'The sub category for the service and category.', description: 'The sub category for the service and category.',
}), }),
subCategoryId: t.exposeID('subCategoryId', { subCategoryId: t.exposeID('subCategoryId', {

View File

@@ -52,13 +52,13 @@ export class UploadedFileSchema extends PothosSchema {
user: t.relation('user', { user: t.relation('user', {
description: 'The user who uploaded the file.', description: 'The user who uploaded the file.',
}), }),
Center: t.relation('Center', { center: t.relation('center', {
description: 'The center that the file belongs to.', description: 'The center that the file belongs to.',
}), }),
Service: t.relation('Service', { service: t.relation('service', {
description: 'The service that the file belongs to.', description: 'The service that the file belongs to.',
}), }),
Workshop: t.relation('Workshop', { workshop: t.relation('workshop', {
description: 'The workshop that the file belongs to.', description: 'The workshop that the file belongs to.',
}), }),
}), }),

View File

@@ -83,10 +83,10 @@ export class UserSchema extends PothosSchema {
centerStaffChatRoom: t.relation('centerStaffChatRoom', { centerStaffChatRoom: t.relation('centerStaffChatRoom', {
description: 'The center staff chat room of the user.', description: 'The center staff chat room of the user.',
}), }),
CenterStaff: t.relation('CenterStaff', { centerStaff: t.relation('centerStaff', {
description: 'The center staff of the user.', description: 'The center staff of the user.',
}), }),
WorkshopSubscription: t.relation('WorkshopSubscription', { workshopSubscription: t.relation('workshopSubscription', {
description: 'The workshop subscription of the user.', description: 'The workshop subscription of the user.',
}), }),
}), }),

View File

@@ -76,7 +76,7 @@ export class WorkshopSchema extends PothosSchema {
staff: t.relation('staff', { staff: t.relation('staff', {
description: 'The staff member who is leading the workshop.', description: 'The staff member who is leading the workshop.',
}), }),
meetingRoom: t.relation('WorkshopMeetingRoom', { meetingRoom: t.relation('workshopMeetingRoom', {
nullable: true, nullable: true,
description: 'The meeting room that the workshop is for.', description: 'The meeting room that the workshop is for.',
}), }),

File diff suppressed because one or more lines are too long