시드 생성
This commit is contained in:
+22
-2
@@ -3,7 +3,7 @@ const { sequelize } = require('../config/database');
|
||||
|
||||
const Club = sequelize.define('Club', {
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
type: DataTypes.INTEGER.UNSIGNED,
|
||||
primaryKey: true,
|
||||
autoIncrement: true
|
||||
},
|
||||
@@ -16,7 +16,7 @@ const Club = sequelize.define('Club', {
|
||||
allowNull: true
|
||||
},
|
||||
ownerId: {
|
||||
type: DataTypes.INTEGER,
|
||||
type: DataTypes.INTEGER.UNSIGNED,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: 'Users',
|
||||
@@ -54,4 +54,24 @@ const Club = sequelize.define('Club', {
|
||||
timestamps: true
|
||||
});
|
||||
|
||||
Club.associate = (models) => {
|
||||
Club.hasMany(models.ClubFeature, { foreignKey: 'clubId' });
|
||||
Club.hasMany(models.ClubSubscription, { foreignKey: 'clubId' });
|
||||
Club.belongsTo(models.User, { foreignKey: 'ownerId', as: 'owner' });
|
||||
Club.belongsToMany(models.Feature, {
|
||||
through: models.ClubFeature,
|
||||
foreignKey: 'clubId',
|
||||
});
|
||||
Club.belongsToMany(models.SubscriptionPlan, {
|
||||
through: models.ClubSubscription,
|
||||
foreignKey: 'clubId',
|
||||
otherKey: 'planId',
|
||||
});
|
||||
Club.hasMany(models.ClubSubscription, { foreignKey: 'clubId' });
|
||||
Club.belongsToMany(models.Feature, {
|
||||
through: models.ClubFeature,
|
||||
foreignKey: 'clubId',
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = Club;
|
||||
|
||||
Reference in New Issue
Block a user