Does anyone have any ideea how to write an OR logic like the ' || ' operator in JS I tried inside my knex to do it like that ->
knex('something')
.where({ state: BOOKING_STATE.ACCEPTED } || { state: BOOKING_STATE.WAITING_LIST})
however it fails and i can't find anything about it in the docs
If you check the documentation for where
clauses with Knex, you'll see a grouped chain where, if you're trying to have multiple where clauses, but only want to or
the two you listed, then something like this would work.
knex('something')
.where(function() {
this.where('state', BOOKING_STATE.ACCEPTED ).orWhere('state', BOOKING_STATE.WAITING_LIST)
})
.andWhere('something', something_else)
...;
You should be able to use a combination of where() and orWhere()
:
knex('something')
.where({ state: BOOKING_STATE.ACCEPTED })
.orWhere({state: BOOKING_STATE.WAITING_LIST })
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