I have below query, I would like to represent this query in knex fromat. I have made it work by usng raw
function but i am curious if it is possible with knex style.
SELECT t.id, t.title, s.userId
FROM title t LEFT JOIN
subscribe s ON t.id = s.titleId AND s.userId = 1;
knex('title as t')
.select('t.id', 't.title', 's.userId')
.leftJoin('subscribe as s', (builder) => {
builder.on('t.id', 's.titleId').on('s.userId', knex.raw('?', [1]));
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With