var Series, Trainer, Video
// Series has a trainer_id=Trainer.id foreign reference key after we call Trainer.hasMany(series) Series = sequelize.define('Series’, { title: DataTypes.STRING, sub_title: DataTypes.STRING, description: DataTypes.TEXT,
// Set FK relationship (hasMany) with Trainer
trainer_id: {
type: DataTypes.INTEGER,
references: "Trainer",
referencesKey: “id”
}
})
Trainer = sequelize.define('Trainer’, { first_name: DataTypes.STRING, last_name: DataTypes.STRING });
Trainer.hasMany(Series);
//用法 Trainer.findAll({ include: [ Series] }).success(function(res) { console.log(JSON.stringify(res)) }) 不能用,求解