members-database/entities/member.ts

63 lines
1.9 KiB
TypeScript

import { Column, Entity, ManyToOne, OneToMany, OneToOne, PrimaryColumn } from "typeorm";
import { Salutation } from "../enums/salutation";
import { membership } from "./membership";
import { member_awards } from "./member_awards";
import { member_qualifications } from "./member_qualifications";
import { member_executive_positions } from "./member_executive_positions";
import { communication } from "./communication";
@Entity()
export class member {
@PrimaryColumn({ generated: "increment", type: "int" })
id: number;
@Column({ type: "varchar", length: 255, unique: true, nullable: true })
member_id?: string;
@Column({ type: "enum", enum: Salutation, default: Salutation.none })
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;
@Column({ type: "date", nullable: true, default: null })
deathdate?: Date;
@Column({ type: "varchar", length: 255, unique: true, nullable: true })
sepa_mandat?: string;
@ManyToOne(() => communication, (member_communications) => member_communications.member)
communications: communication;
@OneToOne(() => communication, {
nullable: true,
})
sendNewsletter: communication;
@OneToMany(() => membership, (membership) => membership.member)
memberships: membership[];
@OneToMany(() => member_executive_positions, (member_executive_positions) => member_executive_positions.member, {
onDelete: "CASCADE",
})
positions: member_executive_positions[];
@OneToMany(() => member_qualifications, (qualification) => qualification.member, {
onDelete: "CASCADE",
})
qualifications: member_qualifications[];
@OneToMany(() => member_awards, (awards) => awards.member, {
onDelete: "CASCADE",
})
awards: member_awards[];
}