misskey-awawa/packages/backend/src/models/entities/PageLike.ts

39 lines
784 B
TypeScript
Raw Normal View History

/*
* SPDX-FileCopyrightText: syuilo and other misskey contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
import { id } from '../id.js';
2022-09-17 18:27:08 +00:00
import { User } from './User.js';
import { Page } from './Page.js';
@Entity()
@Index(['userId', 'pageId'], { unique: true })
export class PageLike {
@PrimaryColumn(id())
public id: string;
@Column('timestamp with time zone')
public createdAt: Date;
@Index()
@Column(id())
public userId: User['id'];
@ManyToOne(type => User, {
2021-12-09 14:58:30 +00:00
onDelete: 'CASCADE',
})
@JoinColumn()
public user: User | null;
@Column(id())
public pageId: Page['id'];
@ManyToOne(type => Page, {
2021-12-09 14:58:30 +00:00
onDelete: 'CASCADE',
})
@JoinColumn()
public page: Page | null;
}