Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
intrn(database): coment votes model
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelo Magtoto committed Oct 11, 2022
1 parent ab5ef35 commit 9afa785
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions database/models/comment_vote.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import {
Table,
Model,
Column,
DataType,
BelongsTo,
ForeignKey
} from "sequelize-typescript"

import User from "%/models/user"
import Comment from "%/models/comment"
import Department from "%/models/department"
import { VoteKind, VoteKindValues } from "$/types/database"

@Table({
"paranoid": true,
"timestamps": true
})
export default class CommentVote extends Model {
@ForeignKey(() => Comment)
@Column({
"allowNull": true,
"defaultValue": null,
"type": DataType.BIGINT
})
commentID!: number|null

@BelongsTo(() => Comment)
comment!: Comment

@ForeignKey(() => Department)
@Column({
"allowNull": true,
"defaultValue": null,
"type": DataType.BIGINT
})
departmentID!: number|null

@BelongsTo(() => Department)
department!: Department|null

@ForeignKey(() => User)
@Column({
"allowNull": false
})
userID!: number

@BelongsTo(() => User)
user!: User

@Column({
"allowNull": false,
"type": DataType.ENUM(
...VoteKindValues
)
})
kind!: VoteKind
}

0 comments on commit 9afa785

Please sign in to comment.