Search code examples
knex.js

In knex, how to access column value in a join without raw?


With knex, is it possible to do this without raw?

q.leftJoin('columnName as cn', raw('?? is true', ['cn.bool']))

I tried

q.leftJoin('columnName as cn', b => {
  b.on('cn.bool', 'is', 'true')
}

But it does not work.


Solution

  • There is no way to make it without raw, since the default behavior of join in next is to join by 2 columns and not by value.