阅读背景:

查询联结表而不在Sequelize中获取两个关联

来源:互联网 

Consider the following models:

考虑以下模型:

var User = sequelize.define('User', {
  _id:{
    type: Datatypes.INTEGER,
    allowNull: false,
    primaryKey: true,
    autoIncrement: true
  },
  name: Datatypes.STRING,
  email:{
    type: Datatypes.STRING,
    unique: {
      msg: 'Email Taken'
    },
    validate: {
      isEmail: true
    }
  }
});

var Location= sequelize.define('Location', {
  _id:{
    type: Datatypes.INTEGER,
    allowNull: false,
    primaryKey: true,
    autoIncrement: true
  },
  name: Datatypes.STRING,
  address: type: Datatypes.STRING
});

Location.belongsToMany(User, {through: 'UserLocation'});
User.belongsToMany(Location, {through: 'UserLocation'});
var 



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: