๐Ÿ“ฆ cityzenKIM / toy_project_board

๐Ÿ“„ PostViews.ts ยท 22 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22import {
  Entity,
  PrimaryGeneratedColumn,
  ManyToOne,
  CreateDateColumn,
  JoinColumn,
} from 'typeorm';
import { Posts } from './Posts';

@Entity({ schema: 'shop', name: 'postViews' })
export class PostViews {
  @PrimaryGeneratedColumn()
  id: number;

  @CreateDateColumn()
  viewedAt: Date;

  @ManyToOne(() => Posts, (post) => post.postViews, { onDelete: 'CASCADE' })
  @JoinColumn([{ name: 'postId', referencedColumnName: 'id' }])
  post: Posts;
}