set @SQL= '
select
pushto as MSISDN,
pushprice as Price,
pushdate as DateTime,
pushtext as Message
from '+@tblname+'
WITH (NOLOCK)
INNER JOIN INAPremium..INA_Keyword K on R.keyid = K.keyid
WHERE '+@sqldate+ @scodelist+ @clientlist + @piclist + @DNType + @pkeywordlist + @seckeywordlist +'
order by pushdate desc'
我不需要此表中的let data = require('./../../config/db')
let connection = data.connection
let sequelize = data.sequelize
let sql = function(){
let clubMembers = connection.define('club_members',{
position:{
type :sequelize.ENUM('President','Treasurer') ,
allowNull : false
}
},
{
classMethods : {
associate : function(models){
let clubMembers = models.club_members
let club = models.club
let student = models.student
club.hasMany(clubMembers,{
foreignKey : "club_id"
})
student.hasMany(clubMembers,{
foreignKey : "student_id"
})
}
}
}
);
return clubMembers;
}
module.exports = sql;
属性,但是sequelize会自动创建它。并且两个外键的组合应被视为主键,即复合主键。
答案 0 :(得分:1)
您应该在associate
功能
belongsToMany
associate: function(models){
models.club.belongsToMany(models.student, { through: models.club_members, foreignKey: 'club_id' });
models.student.belongsToMany(models.club, { through: models.club_members, foreignKey: 'student_id' });
}
这将创建club_members
表,其中包含由club_id
和student_id
组成的复合主键,而不包含默认的id
列。