import { Column, Entity, JoinColumn, JoinTable, ManyToMany, ManyToOne, OneToMany, PrimaryColumn } from "typeorm"; import { executive_position } from "./executive_position"; import { qualification } from "./qualification"; import { city_district } from "./city_district"; import { Salutation } from "../enums/salutation"; import { city } from "./city"; import { membership } from "./membership"; import { NewsletterType } from "../enums/newsletter_type"; import { member_awards } from "./member_awards"; @Entity() export class member { @PrimaryColumn({ generated: "uuid", type: "varchar", length: 36 }) id: string; @Column({ type: "enum", enum: Salutation, default: Salutation.none }) salutation: Salutation; @Column({ type: "varchar", length: 255, unique: true, nullable: true }) member_id?: string; @Column({ type: "varchar", length: 255, unique: true, nullable: true }) sepa_mandat?: string; @Column({ type: "varchar", length: 255 }) firstname: string; @Column({ type: "varchar", length: 255 }) lastname: string; @Column({ type: "varchar", length: 255 }) phone: string; @Column({ type: "varchar", length: 255 }) mobile: string; @Column({ type: "varchar", length: 255 }) email: string; @Column({ type: "varchar", length: 255, nullable: true, default: null }) official_email?: string; @Column({ type: "varchar", length: 255 }) street: string; @Column({ type: "date" }) birthdate: Date; @Column({ type: "date", nullable: true, default: null }) deathdate?: Date; @Column({ type: "boolean", default: false }) push_alert: boolean; @Column({ type: "enum", enum: NewsletterType, default: NewsletterType.Online }) newsletter: NewsletterType; @OneToMany(() => membership, (membership) => membership.member) memberships: membership[]; @ManyToOne(() => city, (city) => city.members) @JoinColumn({ name: "city", }) city: city; @ManyToOne(() => city_district, (city_district) => city_district.members, { nullable: true, }) @JoinColumn({ name: "district", }) city_district: city_district; @ManyToMany(() => executive_position, (executive_position) => executive_position.members, { onDelete: "CASCADE", }) @JoinTable({ name: "member_executive_position" }) positions: executive_position[]; @ManyToMany(() => qualification, (qualification) => qualification.members, { onDelete: "CASCADE", }) @JoinTable({ name: "member_qualification" }) qualifications: qualification[]; @OneToMany(() => member_awards, (awards) => awards.member, { onDelete: "CASCADE", }) awards: member_awards[]; }