From 258272c6dfb34397b17389e456df18f95162a76b Mon Sep 17 00:00:00 2001 From: Net <93821485+somnetsak123@users.noreply.github.com> Date: Wed, 20 Mar 2024 09:09:42 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=20OneToMany?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entities/BloodGroup.ts | 7 ++++++- src/entities/Gender.ts | 7 ++++++- src/entities/Profile.ts | 4 ++++ src/entities/Relationship.ts | 7 ++++++- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/entities/BloodGroup.ts b/src/entities/BloodGroup.ts index 004c5095..11e3fb1e 100644 --- a/src/entities/BloodGroup.ts +++ b/src/entities/BloodGroup.ts @@ -1,6 +1,8 @@ -import { Entity, Column} from "typeorm"; +import { Entity, Column, OneToMany } from "typeorm"; import { EntityBase } from "./base/Base"; +import { ProfileInformation } from "./ProfileInformation"; + @Entity("bloodGroup") export class BloodGroup extends EntityBase { @Column({ @@ -10,6 +12,9 @@ export class BloodGroup extends EntityBase { default: null, }) name: string; + + @OneToMany(() => ProfileInformation, (profileInformation) => profileInformation.bloodGroupId) + profileInformations: ProfileInformation[]; } export class CreateBloodGroup { diff --git a/src/entities/Gender.ts b/src/entities/Gender.ts index dd9cae1e..79d7e6b7 100644 --- a/src/entities/Gender.ts +++ b/src/entities/Gender.ts @@ -1,6 +1,8 @@ -import { Entity, Column} from "typeorm"; +import { Entity, Column, OneToMany } from "typeorm"; import { EntityBase } from "./base/Base"; +import { ProfileInformation } from "./ProfileInformation"; + @Entity("gender") export class Gender extends EntityBase { @Column({ @@ -10,6 +12,9 @@ export class Gender extends EntityBase { default: null, }) name: string; + + @OneToMany(() => ProfileInformation, (profileInformation) => profileInformation.genderId) + profileInformations: ProfileInformation[]; } export class CreateGender { diff --git a/src/entities/Profile.ts b/src/entities/Profile.ts index 3b01f4b3..b70a71b7 100644 --- a/src/entities/Profile.ts +++ b/src/entities/Profile.ts @@ -16,6 +16,7 @@ import { ProfileAbility } from "./ProfileAbility"; import { ProfileDuty } from "./ProfileDuty"; import { ProfileNopaid } from "./ProfileNopaid"; import { ProfileOther } from "./ProfileOther"; +import { ProfileInformation } from "./ProfileInformation"; import { ProfileFamilyHistory } from "./ProfileFamily"; @Entity("profile") @@ -192,6 +193,9 @@ export class Profile extends EntityBase { @ManyToOne(() => PosType, (posType) => posType.profiles) @JoinColumn({ name: "posTypeId" }) posType: PosType; + + @OneToMany(() => ProfileInformation, (profileInformation) => profileInformation.profile) + profileInformation: ProfileInformation[]; } export class CreateProfile { diff --git a/src/entities/Relationship.ts b/src/entities/Relationship.ts index 6a2bbc85..a9b3edd7 100644 --- a/src/entities/Relationship.ts +++ b/src/entities/Relationship.ts @@ -1,6 +1,8 @@ -import { Entity, Column} from "typeorm"; +import { Entity, Column, OneToMany } from "typeorm"; import { EntityBase } from "./base/Base"; +import { ProfileInformation } from "./ProfileInformation"; + @Entity("relationship") export class Relationship extends EntityBase { @Column({ @@ -10,6 +12,9 @@ export class Relationship extends EntityBase { default: null, }) name: string; + + @OneToMany(() => ProfileInformation, (profileInformation) => profileInformation.relationshipId) + profileInformations: ProfileInformation[]; } export class CreateRelationship {