2024-02-11 01:04:12 +00:00
|
|
|
import { DataTypes, Deferrable, Sequelize } from 'sequelize';
|
2024-02-06 15:18:06 +00:00
|
|
|
|
2024-02-11 01:04:12 +00:00
|
|
|
/**
|
|
|
|
* @typedef {Object} RoleEmojiPair
|
|
|
|
* @property {string} id A universally unique id, generated by sequelize.
|
|
|
|
* @property {string} message A Discord message ID as a foreign key reference.
|
|
|
|
* @property {string} role A Discord role ID.
|
|
|
|
* @property {string} emoji Either a unicode emoji or a string representation in Discord custom emoji format.
|
2024-02-11 01:40:26 +00:00
|
|
|
* @property {(model: Object) => void} hasMany Defines an One-To-Many relationship.
|
2024-02-11 01:53:28 +00:00
|
|
|
* @property {(conditions: Object) => Promise<RoleEmojiPair>} findOne Finds one instance in the database matching the provided condition(-s).
|
|
|
|
* @property {(conditions: Object) => Promise<Array<RoleEmojiPair>>} findAll Finds all instances in the database matching the provided condition(-s).
|
2024-02-11 01:04:12 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The definition of the `RoleEmojiPair` table in the database.
|
|
|
|
* @param {Sequelize} sequelize
|
|
|
|
* @returns {RoleEmojiPair}
|
|
|
|
*/
|
2024-02-11 01:55:46 +00:00
|
|
|
export default function (sequelize) {
|
2024-02-06 15:18:06 +00:00
|
|
|
return sequelize.define('RoleEmojiPairs', {
|
|
|
|
id: {
|
|
|
|
defaultValue: DataTypes.UUIDV4,
|
|
|
|
type: DataTypes.UUID,
|
|
|
|
primaryKey: true
|
|
|
|
},
|
|
|
|
message: {
|
|
|
|
type: DataTypes.STRING,
|
|
|
|
references: {
|
|
|
|
deferrable: Deferrable.INITIALLY_IMMEDIATE,
|
|
|
|
model: 'Messages',
|
|
|
|
key: 'id'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
role: {
|
2024-03-02 22:51:18 +00:00
|
|
|
type: DataTypes.STRING,
|
|
|
|
references: {
|
|
|
|
deferrable: Deferrable.INITIALLY_IMMEDIATE,
|
|
|
|
model: 'Roles',
|
|
|
|
key: 'id'
|
|
|
|
}
|
2024-02-06 15:18:06 +00:00
|
|
|
},
|
|
|
|
emoji: {
|
|
|
|
type: DataTypes.STRING
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|