Updated models and migrations to new spec

This commit is contained in:
2022-08-17 19:36:47 +02:00
parent bc075805e2
commit 05804cb78a
22 changed files with 336 additions and 86 deletions

View File

@@ -10,18 +10,16 @@ module.exports = (sequelize, DataTypes) => {
* The `models/index` file will call this method automatically.
*/
static associate(models) {
Character.hasMany(models.Card, {
foreignKey: 'characterID',
as: 'cards'
});
Character.belongsToMany(models.Card, { through: 'CardCharacter' });
Character.belongsTo(models.Band, { foreignKey: 'bandId', });
}
}
Character.init({
name: DataTypes.STRING,
rarity: DataTypes.INTEGER,
description: DataTypes.STRING,
bandId: DataTypes.INTEGER,
imageURL: DataTypes.STRING,
imageHash: DataTypes.STRING
description: DataTypes.TEXT,
enabled: DataTypes.BOOLEAN
}, {
sequelize,
modelName: 'Character',