kex icon indicating copy to clipboard operation
kex copied to clipboard

Add whereHas for checking the relations

Open radmen opened this issue 4 years ago • 0 comments

It would be nice to have a whereHas method which checks if the model has given relation.

await User.query()
  .whereHas('Message')

would result in the following query:

select * from users where exists (
  select * from messages where messages.user_id = users.id
)

radmen avatar May 11 '20 18:05 radmen