added message to database

This commit is contained in:
Baipyrus 2024-01-29 00:31:40 +01:00
parent 8a619b53e4
commit c19ef05c82
2 changed files with 18 additions and 1 deletions

View File

@ -1,3 +1,4 @@
import defineMessage from './models/message.js';
import { Sequelize } from 'sequelize'; import { Sequelize } from 'sequelize';
import { config } from 'dotenv'; import { config } from 'dotenv';
config(); config();
@ -9,7 +10,8 @@ const sequelize = new Sequelize(DB_NAME, DB_USER, DB_PWD, {
logging: false, logging: false,
host: DB_HOST, host: DB_HOST,
}); });
const Message = defineMessage(sequelize);
sequelize.sync(); sequelize.sync();
export { sequelize }; export { sequelize, Message };

15
models/message.js Normal file
View File

@ -0,0 +1,15 @@
import { DataTypes } from "sequelize";
export default function(sequelize) {
return sequelize.define('Message', {
id: {
type: DataTypes.STRING,
primaryKey: true,
},
roleEmojiPair: {
deferrable: Deferrable.INITIALLY_IMMEDIATE,
model: 'RoleEmojiPair',
key: 'id',
},
});
}