yumechi-no-kuni/packages/backend/src/models/entities/clip-note.ts

38 lines
683 B
TypeScript
Raw Normal View History

import { Entity, Index, JoinColumn, Column, ManyToOne, PrimaryColumn } from 'typeorm';
import { Note } from './note';
import { Clip } from './clip';
import { id } from '../id';
@Entity()
@Index(['noteId', 'clipId'], { unique: true })
export class ClipNote {
@PrimaryColumn(id())
public id: string;
@Index()
@Column({
...id(),
2021-12-09 08:58:30 -06:00
comment: 'The note ID.',
})
public noteId: Note['id'];
@ManyToOne(type => Note, {
2021-12-09 08:58:30 -06:00
onDelete: 'CASCADE',
})
@JoinColumn()
public note: Note | null;
@Index()
@Column({
...id(),
2021-12-09 08:58:30 -06:00
comment: 'The clip ID.',
})
public clipId: Clip['id'];
@ManyToOne(type => Clip, {
2021-12-09 08:58:30 -06:00
onDelete: 'CASCADE',
})
@JoinColumn()
public clip: Clip | null;
}