How to make join queries using Sequelize on Node.js

前端 未结 4 1482
情深已故
情深已故 2020-11-28 01:55

I am using sequelize ORM; everything is great and clean, but I had a problem when I use it with join queries. I have two models: users and posts.



        
4条回答
  •  一生所求
    2020-11-28 02:47

    Model1.belongsTo(Model2, { as: 'alias' })
    
    Model1.findAll({include: [{model: Model2  , as: 'alias'  }]},{raw: true}).success(onSuccess).error(onError);
    

提交回复
热议问题