diff --git a/src/entities/mentor.entity.ts b/src/entities/mentor.entity.ts index f14f3fd4..7b5ac353 100644 --- a/src/entities/mentor.entity.ts +++ b/src/entities/mentor.entity.ts @@ -1,11 +1,4 @@ -import { - Column, - Entity, - JoinColumn, - ManyToOne, - OneToMany, - OneToOne -} from 'typeorm' +import { Column, Entity, JoinColumn, ManyToOne, OneToMany } from 'typeorm' import profileEntity from './profile.entity' import Mentee from './mentee.entity' import Category from './category.entity' @@ -30,7 +23,7 @@ class Mentor extends BaseEntity { @Column({ type: 'boolean' }) availability: boolean - @OneToOne(() => profileEntity) + @ManyToOne(() => profileEntity) @JoinColumn() profile: profileEntity diff --git a/src/services/profile.service.ts b/src/services/profile.service.ts index 8039e1b8..acf1346c 100644 --- a/src/services/profile.service.ts +++ b/src/services/profile.service.ts @@ -70,20 +70,13 @@ export const getAllMentorApplications = async ( const existingMentorApplications = await mentorRepository .createQueryBuilder('mentor') - .select([ - 'mentor.state AS state', - 'mentor.availability AS availability', - 'mentor.uuid AS uuid', - 'mentor.created_at AS created_at', - 'mentor.updated_at AS updated_at', - 'mentor.application AS application', - 'category.category AS category', - 'category.uuid AS category_uuid' - ]) - .leftJoin('mentor.category', 'category') + .innerJoinAndSelect('mentor.profile', 'profile') + .innerJoinAndSelect('mentor.category', 'category') + .addSelect('mentor.application') .where('mentor.profile.uuid = :uuid', { uuid: user.uuid }) - .getRawMany() + .getMany() + console.log(existingMentorApplications) if (existingMentorApplications.length === 0) { return { statusCode: 200,