I've been struggling with this problem for hours now... And I can not seem to figure out how to execute the following query using knex query builder...
select * from persons where first_name = "John" and (id_card_number = "1234" or id_card_number_2 = "5678")
Any help would be appreciated.
Thanks
Best Rick
You can pass a function to where, which Knex will wrap all internal changes with parenthesis.
It will look like this:
knex('persons')
.where('first_name', 'John')
.where((whereBuilder) =>
whereBuilder.where('id_card_number', '1234').orWhere('id_card_number_2', '5678')
);
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