mysql - Sequilize association for 2 foriegn key of same model -


i need execute below query using sequelize

select * haulerrfquotes left join quotes on quotes.jobid = haulerrfquotes.jobid , haulerrfquotes.haulerid = quotes.haulerid haulerrfquotes.jobid = '11' 

but not getting how use 2 foriegn keys in same model(haulerrfquotes) , create association of both foriegn keys single model (quotes)

in sequelize, define own join condition supplying on options in include object. here's example perform query in question

haulerrfquotes.findall({     where: {         jobid: 11     },     include: [{         model: quotes,         required: false,         on: {             jobid: {                 $col: 'haulerrfquotes.jobid'             },             haulerid: {                 $col: 'haulerrfquotes.haulerid'             }         }     }] }).then(result => {     // rest of logic here... }); 

Comments

Popular posts from this blog

wireshark - USB mapping with python -

c++ - nodejs socket.io closes connection before upgrading to websocket -

Deploying Qt Application on Android is really slow? -