diff --git a/src/datasources/db/workshopAPI.ts b/src/datasources/db/workshopAPI.ts index b171010..de04f89 100644 --- a/src/datasources/db/workshopAPI.ts +++ b/src/datasources/db/workshopAPI.ts @@ -55,6 +55,8 @@ export class WorkshopAPI extends DataSource { async updateWorkshop (workshop: any, userId: number) { const keepLock = workshop.keepLock; delete workshop.keepLock; + const workshopTypeId = workshop.workshopTypeId; + delete workshop.workshopTypeId; await this.connection.transaction(async (entityManger: EntityManager) => { if (await LockUtils.isLocked(entityManger, Workshop, 'w', workshop.id, userId)) { throw new ResourceLockedError('Workshop', 'Attempting to update locked resource'); @@ -71,6 +73,11 @@ export class WorkshopAPI extends DataSource { throw new NotFoundError('Workshop', 'id', workshop.id); } }); + workshopTypeId && await entityManger.getRepository(Workshop) + .createQueryBuilder('w') + .relation(Workshop, 'workshopTypeId') + .of(workshop.id) + .set(workshopTypeId); }); !keepLock && await this.unlockWorkshop(workshop.id, userId); return await this.workshopById(workshop.id);