whereIn not working with raw in objection js

884 Views Asked by At

I am using Objection.js ORM of Node.js. I want to use whereIn with raw
Here is what I am trying -

var bookingData = await DoctorBookingsModel
.query()
.select('b.id as booking_id','b.appointment_date')
.from('doctor_bookings as b')
.whereIn(raw("DATE(b.appointment_date) = '"+arrUnavailbleDates+"'"))
.first();    

But I am getting following error -

Error: Undefined binding(s) detected when compiling SELECT query: select `b`.`id` as `booking_id`, `b`.`appointment_date` from `doctor_bookings` as `b` where DATE(b.appointment_date) = '2020-10-16,2020-10-17' in ?    

Please help me.
Any help would be appreciated,
Thanks.

1

There are 1 best solutions below

0
On
.whereIn(leftSide, rightSide)

requires 2 arguments. Looks like you were maybe trying to write:

.whereIn(raw("DATE(b.appointment_date)"), arrUnavailbleDates)

a bit like this runkit example https://runkit.com/embed/qm1rwz9dff2h