members-database/entities/member.ts

92 lines
2.6 KiB
TypeScript
Raw Normal View History

2024-08-19 10:47:10 +00:00
import { Column, Entity, JoinColumn, JoinTable, ManyToMany, ManyToOne, OneToMany, PrimaryColumn } from "typeorm";
2024-08-17 14:38:08 +00:00
import { executive_position } from "./executive_position";
import { qualification } from "./qualification";
2024-08-19 10:47:10 +00:00
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";
2024-08-17 14:38:08 +00:00
@Entity()
export class member {
@PrimaryColumn({ generated: "uuid", type: "varchar", length: 36 })
id: string;
2024-08-19 10:47:10 +00:00
@Column({ type: "enum", enum: Salutation, default: Salutation.none })
salutation: Salutation;
@Column({ type: "varchar", length: 255, unique: true, nullable: true })
member_id?: string;
2024-08-17 14:38:08 +00:00
@Column({ type: "varchar", length: 255, unique: true, nullable: true })
2024-08-19 10:47:10 +00:00
sepa_mandat?: string;
2024-08-17 14:38:08 +00:00
@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;
2024-08-19 10:47:10 +00:00
@Column({ type: "varchar", length: 255, nullable: true, default: null })
official_email?: string;
2024-08-17 14:38:08 +00:00
@Column({ type: "varchar", length: 255 })
street: string;
@Column({ type: "date" })
birthdate: Date;
@Column({ type: "date", nullable: true, default: null })
2024-08-19 10:47:10 +00:00
deathdate?: Date;
2024-08-17 14:38:08 +00:00
@Column({ type: "boolean", default: false })
push_alert: boolean;
2024-08-19 10:47:10 +00:00
@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;
2024-08-17 14:38:08 +00:00
@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[];
2024-08-19 10:47:10 +00:00
@OneToMany(() => member_awards, (awards) => awards.member, {
onDelete: "CASCADE",
})
awards: member_awards[];
2024-08-17 14:38:08 +00:00
}