Skip to content

Commit

Permalink
format the response and also include profile
Browse files Browse the repository at this point in the history
  • Loading branch information
Madhawa97 committed Oct 29, 2023
1 parent 0831832 commit f2a95bc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
11 changes: 2 additions & 9 deletions src/entities/mentor.entity.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -30,7 +23,7 @@ class Mentor extends BaseEntity {
@Column({ type: 'boolean' })
availability: boolean

@OneToOne(() => profileEntity)
@ManyToOne(() => profileEntity)
@JoinColumn()
profile: profileEntity

Expand Down
17 changes: 5 additions & 12 deletions src/services/profile.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f2a95bc

Please sign in to comment.