I want to perform a WHERE - IN
query/operation but normal where gives error.
I want this
select * from `calendar_event_rsvp` where `event_id` in ('1', '2', '3')
But below code leads to
select * from `calendar_event_rsvp` where `event_id in` = '1', '2', '3'
Code
CalendarEventRSVP.forge()
.where({
"event_id": event_ids
})
How do i do this in bookshelf.js
Bookshelf.js is a JavaScript ORM for Node.js, built on the Knex SQL query builder. It supports both promise based and traditional callback interfaces. Bookshelf provides transaction support, eager/nested-eager relation loading, polymorphic associations, and support for one-to-one, one-to-many, and many-to-many relations.
Bookshelf.js tutorial shows how to program databases in JavaScript with the Bookshelf.js ORM. Bookshelf.js is built on top of Knex. Bookshelf.js is a JavaScript ORM for Node.js, built on the Knex SQL query builder.
Bookshelf.js is built on top of Knex. Bookshelf.js is a JavaScript ORM for Node.js, built on the Knex SQL query builder. It supports both promise based and traditional callback interfaces.
Bookshelf.js supports promise-based interfaces, which in this case means the anonymous function passed into then will only be called if your query was successful. The model is the resulting JavaScript object, which you can use to access attributes associated with User. In our case model.get ('gender') returns the gender of our user.
Try to add the operator:
CalendarEventRSVP.forge()
.where('event_id', 'in', event_ids)
Or use knex's whereIn
:
CalendarEventRSVP.forge()
.query({whereIn: {event_id: event_ids}})
try query() function on your model.
CalendarEventRSVP.query(function(qb){
qb.where('event_id' , 'in' , [1,2,3,4]) ;
})
.fetchAll()
.then();
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