import { Column, Entity, JoinColumn, ManyToOne, OneToMany, OneToOne, PrimaryColumn } from "typeorm"; import { Salutation } from "../enums/salutation"; import { membership } from "./membership"; import { memberAwards } from "./memberAwards"; import { memberQualifications } from "./memberQualifications"; import { memberExecutivePositions } from "./memberExecutivePositions"; import { communication } from "./communication"; import { CommunicationViewModel } from "../viewmodel/admin/communication.models"; @Entity() export class member { @PrimaryColumn({ generated: "increment", type: "int" }) id: number; @Column({ type: "varchar", length: "255", default: Salutation.none.toString(), transformer: { to(value: Salutation) { return value.toString(); }, from(value: string) { return Salutation[value as keyof typeof Salutation]; }, }, }) salutation: Salutation; @Column({ type: "varchar", length: 255 }) firstname: string; @Column({ type: "varchar", length: 255 }) lastname: string; @Column({ type: "varchar", length: 255 }) nameaffix: string; @Column({ type: "date" }) birthdate: Date; @OneToMany(() => communication, (communications) => communications.member) communications: communication[]; @OneToOne(() => communication, { nullable: true, onDelete: "SET NULL", onUpdate: "RESTRICT", }) @JoinColumn() sendNewsletter?: communication; @OneToMany(() => membership, (membership) => membership.member) memberships: membership[]; @OneToMany(() => memberAwards, (awards) => awards.member) awards: memberAwards[]; @OneToMany(() => memberExecutivePositions, (executivePositions) => executivePositions.member) positions: memberExecutivePositions[]; @OneToMany(() => memberQualifications, (qualifications) => qualifications.member) qualifications: memberQualifications[]; firstMembershipEntry?: membership; lastMembershipEntry?: membership; preferredCommunication?: Array; smsAlarming?: Array; }