CoastalCommitsPastes/server/lib/models/PostAuthor.ts
2022-03-06 16:46:59 -08:00

22 lines
447 B
TypeScript

import { Model, Column, Table, ForeignKey, IsUUID, PrimaryKey, DataType } from "sequelize-typescript";
import { Post } from "./Post";
import { User } from "./User";
@Table
export class PostAuthor extends Model {
@IsUUID(4)
@PrimaryKey
@Column({
type: DataType.UUID,
defaultValue: DataType.UUIDV4,
})
id!: string
@ForeignKey(() => Post)
@Column
postId!: number;
@ForeignKey(() => User)
@Column
authorId!: number;
}