【发布时间】:2021-06-02 17:49:57
【问题描述】:
我有一个查询需要转换为 ORM Sequelize(使用 MySQL 作为 DB)
select departments.name_department, products.name, products.descricao, products.disponivel, products.destaque, produts.estoque
from products
inner join departments
on id_dep = departments.id
where id_dep = req.params
试过了
async productByDep(req,res){
const {id} = req.params;
Departments.hasMany(Product, {foreignKey: 'id_dep'})
Product.belongsTo(Department)
Product.findAll({where: {id_dep : id}})
}
但我得到的查询与第一个完全不同。
【问题讨论】:
标签: mysql node.js sequelize.js crud