Refactor to more consistent structure (e.g. "plugins")
This commit is contained in:
41
plugins/remind/models.ts
Normal file
41
plugins/remind/models.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { BOOLEAN, DATE, INTEGER, Model, Sequelize, TEXT } from "sequelize";
|
||||
|
||||
export class Reminder extends Model {
|
||||
declare id: number;
|
||||
declare userId: string;
|
||||
declare text: string | null;
|
||||
declare trigger: Date;
|
||||
declare isValid: boolean;
|
||||
declare requestChannel: string;
|
||||
declare requestMessage: string;
|
||||
}
|
||||
|
||||
export function initializeModels(sequelize: Sequelize) {
|
||||
Reminder.init(
|
||||
{
|
||||
id: {
|
||||
type: INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
userId: {
|
||||
type: TEXT,
|
||||
allowNull: false,
|
||||
},
|
||||
text: TEXT,
|
||||
trigger: {
|
||||
type: DATE,
|
||||
allowNull: false,
|
||||
},
|
||||
isValid: BOOLEAN,
|
||||
requestChannel: TEXT,
|
||||
requestMessage: TEXT,
|
||||
},
|
||||
{sequelize},
|
||||
);
|
||||
// await Reminder.sync(); // TODO
|
||||
}
|
||||
|
||||
export async function syncModels() {
|
||||
await Reminder.sync();
|
||||
}
|
||||
Reference in New Issue
Block a user