我在现有架构上使用Sequelize,并想知道如何应对以下情况:
我有一个站点表(其中站点有国际民航组织机场标识符):
var Site = sequelize.define('site', {
uid: {
type: DataTypes.INTEGER,
primaryKey: true
},
icao: {
type: 'CHARACTER',
allowNull: false
}
});
还有一张包含天气时间序列的表格(在国际民航组织和日期上使用复合主键):
var Weather = sequelize.define('weather', {
icao: {
type: DataTypes.TEXT,
primaryKey: true
},
date: {
type: DataTypes.DATE,
primaryKey: true
},
icon: {
type: DataTypes.TEXT,
allowNull: false
}
});
我相信这是属于属性的关联,但没有连接表 . 有没有办法用Sequelize模型和关联映射此模式?
我尝试使用 site
表作为连接表:
Site.belongsToMany(Weather, {through: 'site'});
但是自 column site.site_uid does not exist
以来这不起作用 .