sharkey/packages/backend/src/models/entities/clip-note.ts

38 lines
692 B
TypeScript
Raw Normal View History

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