Generate the whereIn statement


#1

I have this code below in getting all the ids
const production_groups = await ProductionGroup.query().select(‘id’,‘production_group’).orderBy(‘id’,‘desc’).fetch()
var all_production_group = production_groups.toJSON()

Now my problem is how to put the data in the whereIn.
Below code:
var projects_temp = await Project.query().select(‘projects.id’,‘projects.start_date’,‘projects.end_date’,‘projects.status’,‘services.service_name’,‘clients.client_name’,‘projects.wo_ref’,‘production_groups.color_code’,‘production_groups.id AS production_group_id’)
.leftJoin(‘services’,‘services.id’,‘projects.service_id’)
.leftJoin(‘clients’,‘clients.id’,‘projects.client_id’)
.leftJoin(‘production_groups’,‘production_groups.id’,‘projects.production_group_id’)
.whereIn(‘projects.production_group_id’,[data])
.fetch()

Thanks for help. Highly appreciated.