Sharkey/packages/backend/src/models/entities/muted-note.ts

49 lines
941 B
TypeScript
Raw Normal View History

import { Entity, Index, JoinColumn, Column, ManyToOne, PrimaryColumn } from 'typeorm';
import { Note } from './note.js';
import { User } from './user.js';
import { id } from '../id.js';
import { mutedNoteReasons } from '../../types.js';
@Entity()
@Index(['noteId', 'userId'], { unique: true })
export class MutedNote {
@PrimaryColumn(id())
public id: string;
@Index()
@Column({
...id(),
2021-12-09 16:58:30 +02:00
comment: 'The note ID.',
})
public noteId: Note['id'];
@ManyToOne(type => Note, {
2021-12-09 16:58:30 +02:00
onDelete: 'CASCADE',
})
@JoinColumn()
public note: Note | null;
@Index()
@Column({
...id(),
2021-12-09 16:58:30 +02:00
comment: 'The user ID.',
})
public userId: User['id'];
@ManyToOne(type => User, {
2021-12-09 16:58:30 +02:00
onDelete: 'CASCADE',
})
@JoinColumn()
public user: User | null;
/**
*
*/
@Index()
@Column('enum', {
enum: mutedNoteReasons,
2021-12-09 16:58:30 +02:00
comment: 'The reason of the MutedNote.',
})
public reason: typeof mutedNoteReasons[number];
}