import { Table, Column, Model, DataType, Length, ForeignKey, BelongsTo } from "sequelize-typescript"; import User from "./user.model"; import Thread from "./thread.model"; @Table({ timestamps: false, tableName: "messages", modelName: "Message" }) export default class Message extends Model { @Column({ primaryKey: true, autoIncrement: true, type: DataType.INTEGER }) declare id: number; @Length({ min: 1 }) @Column({ allowNull: false, defaultValue: "Unknown", type: DataType.STRING }) declare text: string; @ForeignKey(() => User) @Column({ allowNull: false, type: DataType.INTEGER }) declare user_id: number; @BelongsTo(() => User) declare user: User; @ForeignKey(() => Thread) @Column({ allowNull: false, type: DataType.INTEGER }) declare thread_id: number; @BelongsTo(() => Thread) declare thread: Thread; }