DiscordJS-Example/models/responses.js
2024-04-03 19:32:16 +02:00

38 lines
877 B
JavaScript

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
}
});
}