generated from Baipyrus/DiscordJS-Template
defined (message-) keyword model
This commit is contained in:
parent
d67242374e
commit
7b56d96c3c
@ -1,6 +1,7 @@
|
||||
import defineRoleEmojiPair from './models/roleEmojiPairs.js';
|
||||
import defineVoiceChannel from './models/voiceChannels.js';
|
||||
import defineMessage from './models/messages.js';
|
||||
import defineKeyword from './models/keywords.js';
|
||||
import defineGuild from './models/guilds.js';
|
||||
import defineRole from './models/roles.js';
|
||||
import { Sequelize } from 'sequelize';
|
||||
@ -16,6 +17,8 @@ const sequelize = new Sequelize({
|
||||
logging: false
|
||||
});
|
||||
|
||||
const Keyword = defineKeyword(sequelize);
|
||||
|
||||
const RoleEmojiPair = defineRoleEmojiPair(sequelize);
|
||||
|
||||
const VoiceChannel = defineVoiceChannel(sequelize);
|
||||
@ -27,6 +30,7 @@ const Role = defineRole(sequelize);
|
||||
Role.hasMany(RoleEmojiPair, { foreignKey: 'role', onDelete: 'CASCADE' });
|
||||
|
||||
const Guild = defineGuild(sequelize);
|
||||
Guild.hasMany(Keyword, { foreignKey: 'guild', onDelete: 'CASCADE' });
|
||||
Guild.hasMany(VoiceChannel, { foreignKey: 'guild', onDelete: 'CASCADE' });
|
||||
Guild.hasMany(Message, { foreignKey: 'guild', onDelete: 'CASCADE' });
|
||||
Guild.hasMany(Role, { foreignKey: 'guild', onDelete: 'CASCADE' });
|
||||
|
33
models/keywords.js
Normal file
33
models/keywords.js
Normal file
@ -0,0 +1,33 @@
|
||||
import { DataTypes, Deferrable, Sequelize } from 'sequelize';
|
||||
|
||||
/**
|
||||
* @typedef {Object} Keyword
|
||||
* @property {string} id A universally unique id, generated by sequelize.
|
||||
* @property {string} guild A Discord guild ID as a foreign key reference.
|
||||
* @property {string} name The name of the keyword.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The definition of the `Keyword` table in the database.
|
||||
* @param {Sequelize} sequelize
|
||||
*/
|
||||
export default function (sequelize) {
|
||||
return sequelize.define('Keywords', {
|
||||
id: {
|
||||
defaultValue: DataTypes.UUIDV4,
|
||||
type: DataTypes.UUID,
|
||||
primaryKey: true
|
||||
},
|
||||
guild: {
|
||||
type: DataTypes.STRING,
|
||||
references: {
|
||||
deferrable: Deferrable.INITIALLY_IMMEDIATE,
|
||||
model: 'Guilds',
|
||||
key: 'id'
|
||||
}
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING
|
||||
}
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user