How to implement AND OR AND query


#1

Hi,

Any thoughts how to implement AND OR AND conditions(orwhere) on a query. for a given example below

select * from payments
where (
(type=‘CASH’ and amount >1000)
or
(type=‘CHEQUE’ and amount >5000) )

Thanks


#2

Adonis uses Knexjs under the hood. Check out their documentation.

What have you tried so far? Here is what I was able to whip up.

payments.where('amount', '>', 1000).andWhere('type', 'CASH')
.orWhere('amount', '>', 5000 ).andWhere('type', CHEQUE')'

If this is unsuitable try using whereRaw()