2025-05-03 21:12:58 +08:00

44 lines
1.1 KiB
TypeScript

import { DBModel, Sequelize, SyncOptions } from '@kevisual/db';
import { DataTypes } from 'sequelize';
export class Comment extends DBModel {
declare id: number;
declare content: string;
declare note_id: string;
declare user_id: string;
declare comment_id: string;
declare created_at: Date;
declare updated_at: Date;
static async initModel(sequelize: Sequelize, opts?: SyncOptions) {
Comment.init(
{
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
},
content: {
type: DataTypes.TEXT,
allowNull: false,
},
note_id: {
type: DataTypes.STRING,
allowNull: false,
},
user_id: {
type: DataTypes.STRING,
allowNull: false,
},
comment_id: {
type: DataTypes.STRING,
allowNull: false,
},
},
{
sequelize, // passing the `sequelize` instance is required
modelName: 'Comment', // we need to choose the model name
},
);
await Comment.sync(opts || {});
}
}