Multiple top-level filter conditions on the same embedded resource #3776
-
https://docs.postgrest.org/en/stable/references/api/resource_embedding.html#top-level-filtering explains how to: get only the As I am struggling getting queries that reference the same embedded resource multiple times to work, I think having more examples would help:
In reality I have a slightly different database setup but I think these examples would help others and certainly me. I have the equivalent of Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
You have multiple options here, but all the same idea:
You need multiple embeddings for that case. Same as in SQL, where you'd need multiple JOINs or EXISTS subqueries.
Putting the first two together, that's simple:
Tiny adjustment from the first case:
I think the step that is hard to take mentally is that you'll need to add multiple embeddings in some cases. Especially, when you consider the case "give me only the films with Jehanne as an actor, but return all actors for that film". Then you'll need one |
Beta Was this translation helpful? Give feedback.
-
Thank you! I tried to fix the examples and I think I was successful as it now (rightfully) complains with
Is the data behind the examples available? Then I would set it up and test with the actual data. |
Beta Was this translation helpful? Give feedback.
You have multiple options here, but all the same idea:
/films?select=title,actors!inner(first_name,last_name)&actors.first_name=in.Jehanne,John
/films?select=title,actors!inner(first_name,last_name)&or=(actors.first_name.eq.Jehanne,actors.first_name.eq.John)
You need multiple embeddings for that case. Same as in SQL, where you'd need multiple JOINs or EXISTS subqueries.
/films?select=title,jehanne:actors!inner(first_name,last_name),john:actors!inner(first_name,last_nam…