Хотя кажется, что мои ассоциации, определенные в базе данных, когда я вызываю команду create на моих manufacturer
ассоциациях моделей, не создаются.
Это мои связанные модели.
ManufacturerText.associate = function (models) {
models.manufacturer_text.belongsTo(models.language, {
as: 'language'
});
models.manufacturer_text.belongsTo(models.manufacturer, {
as: 'manufacturer'
});
};
ManufacturerVideo.associate = function (models) {
models.manufacturer_video.belongsTo(models.language, {
as: 'language'
});
models.manufacturer_video.belongsTo(models.video_type, {
as: 'video_type'
});
models.manufacturer_video.belongsTo(models.manufacturer, {
as: 'manufacturer'
});
}
И этоэто основная модель: `` `
Manufacturer.associate = function(models) {
// models
models.manufacturer.hasMany(models.manufacturer_text, {foreignKey:'manufacturer_id', as: 'manufacturer_translations' });
models.manufacturer.hasMany(models.manufacturer_video, {foreignKey:'manufacturer_id', as: 'manufacturer_videos' });
models.manufacturer.hasMany(models.inspiration_image, {foreignKey:'manufacturer_id', as: 'inspirations' });
models.manufacturer.belongsTo(models.file, {as: 'image'});
models.manufacturer.belongsTo(models.file, {as: 'header_image'});
};
. Ни одна из двух вышеупомянутых ассоциаций не работает.
Когда я проверяю БД с помощью MySQL Workbench, кажется, что ассоциации определены правильно.