feat: チャンネルをお気に入りに登録できるように

Resolve #10097
This commit is contained in:
syuilo
2023-03-31 11:30:27 +09:00
parent 5d94062581
commit 3cb0cc7989
17 changed files with 327 additions and 10 deletions

View File

@@ -0,0 +1,41 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
import { id } from '../id.js';
import { User } from './User.js';
import { Channel } from './Channel.js';
@Entity()
@Index(['userId', 'channelId'], { unique: true })
export class ChannelFavorite {
@PrimaryColumn(id())
public id: string;
@Index()
@Column('timestamp with time zone', {
comment: 'The created date of the ChannelFavorite.',
})
public createdAt: Date;
@Index()
@Column({
...id(),
})
public channelId: Channel['id'];
@ManyToOne(type => Channel, {
onDelete: 'CASCADE',
})
@JoinColumn()
public channel: Channel | null;
@Index()
@Column({
...id(),
})
public userId: User['id'];
@ManyToOne(type => User, {
onDelete: 'CASCADE',
})
@JoinColumn()
public user: User | null;
}