You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
678 B
TypeScript
27 lines
678 B
TypeScript
5 years ago
|
import * as sqz from "sequelize";
|
||
5 years ago
|
import {Column, ForeignKey, Model, NotNull, Table,} from "sequelize-typescript";
|
||
5 years ago
|
import {Post} from "./Post";
|
||
|
import {User} from "./User";
|
||
|
|
||
|
export enum VoteType {
|
||
|
UPVOTE = "UPVOTE",
|
||
|
DOWNVOTE = "DOWNVOTE",
|
||
|
}
|
||
|
|
||
|
@Table({underscored: true})
|
||
|
export class PostVote extends Model<PostVote> {
|
||
5 years ago
|
@NotNull
|
||
|
@Column({type: sqz.ENUM, values: ["UPVOTE", "DOWNVOTE"], defaultValue: "UPVOTE", allowNull: false})
|
||
5 years ago
|
public voteType: VoteType;
|
||
|
|
||
|
@ForeignKey(() => User)
|
||
5 years ago
|
@NotNull
|
||
|
@Column({allowNull: false})
|
||
5 years ago
|
public userId: number;
|
||
|
|
||
|
@ForeignKey(() => Post)
|
||
5 years ago
|
@NotNull
|
||
|
@Column({allowNull: false})
|
||
5 years ago
|
public postId: number;
|
||
|
}
|