feat: เพิ่ม OneToMany

This commit is contained in:
Net 2024-03-20 09:09:42 +07:00
parent 049b591c77
commit 258272c6df
4 changed files with 22 additions and 3 deletions

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {