How to join two tables, apply where on both tables , apply pagination with bookshelf node js

62 Views Asked by At

I have two tables mentioned below: Reports Id |status 1 |Active

Reports_details Id| Cntry| State | City 1 | IN | UP | Delhi 1 | US | Texas | Salt lake

Now my requirement is Select distinct r.Id from Reports r left join Reports_details rd on r.Id=rd.Id where r.status=‘Active’ and contains(city,’”Del*”’)

Note: using contains for full text search

Problem: How to add where clause on both tables Bookshelf Model simultaneously and how to fetch above query data with pagination

Tried created 2 respective Models with belongs on and hasMany but issue comes when applying where on either Model, it’s not accepting where clause from both table-error:Invalid column name

Appreciate your suggestion on the work around. Thank You

0

There are 0 best solutions below