Files
social-router/packages/xhs/src/services/xhs-db/comment.ts
2025-05-03 04:48:12 +08:00

45 lines
1.2 KiB
TypeScript

import { InitOptions, Model, Sequelize, SyncOptions } from 'sequelize';
import { DataTypes } from 'sequelize';
export class Comment extends Model {
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, initOptions?: InitOptions, 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
...initOptions,
},
);
await Comment.sync(opts || {});
}
}