首页 > sequelize 如何进行联合查询

sequelize 如何进行联合查询

现在假设有三个表,Program(方案表,1个方案多个实施), Implementation(实施表,1个实施有一个工具;该表字段program_id指向program的自增ID,该表字段tool_id指向tools的自增ID), Tools(工具表)

Program = sequelize.define('program', {
  program_id : {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
});
Implementation = sequelize.define('implementation', {
  implementation_id : {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  program_id: {
    type: DataTypes.INTEGER,
  },
  tool_id: {
    type: DataTypes.INTEGER,
  },
});
Tools= sequelize.define('tools', {
  tool_id : {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
});

请问该如何定义associate?

【热门文章】
【热门文章】