generated from Baipyrus/DiscordJS-Template
defined (keyword-) response model
This commit is contained in:
parent
7b56d96c3c
commit
62cf257d73
@ -1,5 +1,6 @@
|
||||
import defineRoleEmojiPair from './models/roleEmojiPairs.js';
|
||||
import defineVoiceChannel from './models/voiceChannels.js';
|
||||
import defineResponse from './models/responses.js';
|
||||
import defineMessage from './models/messages.js';
|
||||
import defineKeyword from './models/keywords.js';
|
||||
import defineGuild from './models/guilds.js';
|
||||
@ -17,7 +18,10 @@ const sequelize = new Sequelize({
|
||||
logging: false
|
||||
});
|
||||
|
||||
const Response = defineResponse(sequelize);
|
||||
|
||||
const Keyword = defineKeyword(sequelize);
|
||||
Keyword.hasMany(Response, { foreignKey: 'keyword', onDelete: 'CASCADE' });
|
||||
|
||||
const RoleEmojiPair = defineRoleEmojiPair(sequelize);
|
||||
|
||||
|
37
models/responses.js
Normal file
37
models/responses.js
Normal file
@ -0,0 +1,37 @@
|
||||
import { DataTypes, Deferrable, Sequelize } from 'sequelize';
|
||||
|
||||
/**
|
||||
* @typedef {Object} Response
|
||||
* @property {string} id A universally unique id, generated by sequelize.
|
||||
* @property {string} keyword A universally unique id referencing a `Keyword`.
|
||||
* @property {string} name The name of the response.
|
||||
* @property {string} response The response data itself.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The definition of the `Response` table in the database.
|
||||
* @param {Sequelize} sequelize
|
||||
*/
|
||||
export default function (sequelize) {
|
||||
return sequelize.define('Responses', {
|
||||
id: {
|
||||
defaultValue: DataTypes.UUIDV4,
|
||||
type: DataTypes.UUID,
|
||||
primaryKey: true
|
||||
},
|
||||
keyword: {
|
||||
type: DataTypes.UUID,
|
||||
references: {
|
||||
deferrable: Deferrable.INITIALLY_IMMEDIATE,
|
||||
model: 'Keywords',
|
||||
key: 'id'
|
||||
}
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING
|
||||
},
|
||||
response: {
|
||||
type: DataTypes.STRING
|
||||
}
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user