node.js开发环境中基于sequelize对mysql基本操作,主外建是怎么用的呢?
发布于 1年前 作者 zhouchengcslngt 1102 次浏览

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)) }) 不能用,求解

回到顶部