만들어 놓고 하다보면 다시 수정하고 수정하는 것이 반복되었다.
며칠을 잡아먹은건지 🙄
user - payment
< 1:N >
user - point
< 1:N >
user - seat
< 1:N >
payment - seat
< 1:N >
point - seat
< 1:1 >
performance - seat
< 1:N >
performance - schedule
< 1:N >
schedule - seat
< 1:N >
import { Performance } from 'src/performance/entities/performance.entity';
import { Seat } from 'src/seat/entities/seat.entity';
import {
Column,
Entity,
ManyToOne,
OneToMany,
PrimaryGeneratedColumn,
} from 'typeorm';
@Entity({
name: 'schedule',
})
export class Schedule {
@PrimaryGeneratedColumn({ name: 'schedule_id' })
id: number;
@Column({ type: 'varchar', nullable: false })
date: string;
@Column({ type: 'varchar', nullable: false })
start_at: string;
@Column({ type: 'varchar', nullable: false })
end_at: string;
@OneToMany(() => Seat, (seat) => seat.schedule)
seats: Seat[];
@ManyToOne(() => Performance, (performance) => performance.schedule, {
onDelete: 'CASCADE',
})
performance: Performance;
}
...
@OneToMany(() => Schedule, (schedule) => schedule.performance)
schedule: Schedule[]; // 추가
}
...
@ManyToOne(() => Schedule, (schedule) => schedule.seats)
schedule: Schedule; // 추가
}