Mistake on query builder #1783
-
Hey, Iam trying to filter a list with query builder, something like: const query = request.clinic.appointments().orderBy('date', orderBy).with('patient', builder => builder.where('id', '3')) But the response is bringing all appointments, instead the appointments with patient with id = 3. Details: |
Beta Was this translation helpful? Give feedback.
Answered by
RomainLanz
Oct 22, 2020
Replies: 1 comment 1 reply
-
Hey @rhadamez! 👋 In this case, your code is wrong, you need to use the |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
rhadamez
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @rhadamez! 👋
In this case, your code is wrong, you need to use the
whereHas
method and notwith
.https://preview.adonisjs.com/guides/model-relations/introduction#querying-relationship-existence