DiscordJS-Template/database.js

24 lines
703 B
JavaScript
Raw Normal View History

2024-02-06 15:18:06 +00:00
import defineRoleEmojiPair from './models/roleEmojiPairs.js';
import defineVoiceChannel from './models/voiceChannels.js';
import defineMessage from './models/messages.js';
import { Sequelize } from 'sequelize';
import { config } from 'dotenv';
config();
const { DB_NAME } = process.env;
const sequelize = new Sequelize({
storage: `${DB_NAME}.sqlite`,
dialect: 'sqlite',
logging: false
});
2024-02-07 20:02:37 +00:00
2024-02-06 15:18:06 +00:00
const RoleEmojiPair = defineRoleEmojiPair(sequelize);
2024-02-07 20:02:37 +00:00
2024-02-06 15:18:06 +00:00
const VoiceChannel = defineVoiceChannel(sequelize);
2024-02-07 20:02:37 +00:00
2024-02-06 15:18:06 +00:00
const Message = defineMessage(sequelize);
2024-02-07 20:02:37 +00:00
Message.hasMany(RoleEmojiPair, { foreignKey: 'message', onDelete: 'CASCADE' });
2024-02-06 15:18:06 +00:00
sequelize.sync();
export { sequelize, RoleEmojiPair, VoiceChannel, Message };