How can I get a list of PK entries in a single request using bookshelf.js ?
The final query should be equivalent to:
SELECT * FROM `user` WHERE `id` IN (1,3,5,6,7);
This solution works:
AdModel .where('search_id', 'IN', [1, 2, 3]) .fetchAll();
You can also use Knex QueryBuilder to get the same result.
AdModel .query(qb => { qb.whereIn('search_id', [1, 2, 3]); }) .fetchAll();
List (single) query and select relationships (withRelated)
BookshelfModel .where('field_id', 'IN', [1, 2, 3]) .fetchAll({withRelated: ["tableA", "tableB"]});