imaginar/models/isotope.js
2024-10-19 20:24:54 +09:00

53 lines
1.0 KiB
JavaScript

'use strict';
module.exports = (sequelize, DataTypes) => {
const Isotope = sequelize.define('Isotope', {
id: {
type: DataTypes.BIGINT,
autoIncrement: true,
primaryKey: true
},
name: {
type: DataTypes.STRING,
allowNull: false
},
firstPerson: {
type: DataTypes.STRING,
allowNull: false
},
personality: {
type: DataTypes.STRING,
allowNull: true
},
tone: {
type: DataTypes.STRING,
allowNull: true
},
backgroundStory: {
type: DataTypes.TEXT,
allowNull: true
},
likes: {
type: DataTypes.STRING,
allowNull: true
},
dislikes: {
type: DataTypes.STRING,
allowNull: true
},
user_id: {
type: DataTypes.BIGINT,
allowNull: false
}
}, {
tableName: 'isotopes',
underscored: true,
timestamps: true
});
Isotope.associate = function(models) {
Isotope.belongsTo(models.User, { foreignKey: 'user_id', onDelete: 'CASCADE' });
};
return Isotope;
};