Reputation: 522
How can I write the below query in bookshelf.js?
select * from Table where (b=2 or b=3) and c = 4;
I am mainly concerned about the nested part (b=2 or b=3).
Upvotes: 0
Views: 1651
Reputation: 1
BookShelfTabelModel.where((qb) => {
qb.where((qb1) => {
qb1
.where({
b: 2,
})
.orWhere({
b: 3,
});strong text
});
qb.andWhere({ c: 4 });
}).fetchAll()
Note
Upvotes: 0
Reputation: 522
Since bookshelf is built on knex, I was searching for this in knex.js documentation.
Reference Link: https://knexjs.org/#Builder-where
knex('Table').where(function(){
this.where('b', 2).orWhere('b', 3)
}).andWhere({'c': 4})
Upvotes: 3