mizzkey/packages/backend/src/models/entities/ClipNote.ts

38 lines
692 B
TypeScript
Raw Normal View History

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