Multicylinders

This commit is contained in:
Bastian Wagner
2025-01-02 11:17:28 +01:00
parent 66302ff05a
commit bf64103369
12 changed files with 199 additions and 34 deletions

View File

@@ -4,6 +4,7 @@ import {
CreateDateColumn,
DeleteDateColumn,
Entity,
ManyToMany,
ManyToOne,
OneToMany,
PrimaryGeneratedColumn,
@@ -20,7 +21,7 @@ export class Cylinder {
@Column({ nullable: false, unique: true })
name: string;
@OneToMany(() => Key, (key) => key.cylinder)
@ManyToMany(() => Key, (key) => key.cylinder)
keys: Key[];
@ManyToOne(() => KeySystem, (sys) => sys.cylinders)

View File

@@ -3,6 +3,8 @@ import {
CreateDateColumn,
DeleteDateColumn,
Entity,
JoinTable,
ManyToMany,
ManyToOne,
PrimaryGeneratedColumn,
UpdateDateColumn,
@@ -28,8 +30,9 @@ export class Key implements IKey {
@Column({ name: 'lost', default: false })
keyLost: boolean;
@ManyToOne(() => Cylinder, (cylinder) => cylinder.keys)
cylinder: Cylinder;
@ManyToMany(() => Cylinder, (cylinder) => cylinder.keys)
@JoinTable()
cylinder: Cylinder[];
@ManyToOne(() => Customer, (customer) => customer.keys)
customer: Customer;

View File

@@ -2,6 +2,7 @@ import {
Column,
CreateDateColumn,
Entity,
ManyToMany,
ManyToOne,
PrimaryGeneratedColumn,
} from 'typeorm';
@@ -27,8 +28,8 @@ export class KeyActivity implements IKey {
@Column({ name: 'handed_out', default: false })
handedOut: boolean;
@ManyToOne(() => Cylinder)
cylinder: Cylinder;
@ManyToMany(() => Cylinder)
cylinder: Cylinder[];
@ManyToOne(() => Customer)
customer: Customer;