import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm"; import { EntityBase } from "./base/Base"; import { District } from "./District"; @Entity("subDistrict") export class SubDistrict extends EntityBase { @Column({ nullable: true, comment: "แขวง", length: 255, default: null, }) name: string; @Column({ nullable: true, comment: "รหัสไปรษณีย์", length: 10, default: null, }) zipCode: string; @Column({ length: 40, comment: "คีย์นอก(FK)ของตาราง district", }) districtId: string; @ManyToOne(() => District, (district) => district.subDistricts) @JoinColumn({ name: "districtId" }) district: District; @OneToMany(() => SubDistrict, (subDistrict) => subDistrict.registrationSubDistricts) registrationSubDistricts: SubDistrict[]; @OneToMany(() => SubDistrict, (subDistrict) => subDistrict.currentSubDistricts) currentSubDistricts: SubDistrict[]; } export class CreateSubDistrict { @Column() name: string; } export type UpdateSubDistrict = Partial;