Add card and character tables

This commit is contained in:
2022-04-17 19:38:50 +02:00
parent 0419733925
commit 9f568dbbdb
5 changed files with 153 additions and 1 deletions

30
models/character.js Normal file
View File

@@ -0,0 +1,30 @@
'use strict';
const {
Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
class Character extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
*/
static associate(models) {
Character.hasMany(models.Card, {
foreignKey: 'characterID',
as: 'cards'
});
}
}
Character.init({
name: DataTypes.STRING,
rarity: DataTypes.INTEGER,
description: DataTypes.STRING,
imageURL: DataTypes.STRING,
imageHash: DataTypes.STRING
}, {
sequelize,
modelName: 'Character',
});
return Character;
};