Where based on relationship condition #1392
-
Is there a way to query records based on relationship condition? I have an Account and AccountProfile model, account hasOne profile, how could I query accounts based on profile status attribute ? In v4 this could be done with:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
Where in the docs you found |
Beta Was this translation helpful? Give feedback.
-
I don't think you can do that, the reason being that Lucid likely runs the query sequentially. That is, it fetches the account model first and secondly fetches the profile model. So, your condition will only be run against the profile model while fetching it. What you could do is to fetch the account models and filters the result at the application level |
Beta Was this translation helpful? Give feedback.
Where in the docs you found
this.related('profile', 'status', status)
?