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

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -