2

So I have this query

return await Order
      .query()
      .with('order_status')
      .where('order_status.is_completed_type', true)

I want to only get the orders with order_status.is_completed_type === true

but it seems that doesn't work that way, is there a way to do this?

frost kazuma
  • 350
  • 1
  • 8
  • 24

1 Answers1

0

You can do it by passing query builder config to .with method: https://adonisjs.com/docs/4.1/relationships#_adding_runtime_constraints

So in your case:

return await Order
      .query()
      .with('order_status', q=> {
          q.where('is_completed_type', true)
})
hlozancic
  • 1,489
  • 18
  • 31