Skip to content

OR with a mix of root and embedded resources #3333

Closed Answered by laurenceisla
joachimlucas asked this question in Q&A
Discussion options

You must be logged in to vote

Hello! To do an OR across embedded resources you need to use not.is.null for the resources inside an or. But, in your case, since you want to filter the top resource suppliers with an embedded resource, you don't need to use not.is.null for the top one. In other words, in your first example, to add an OR code = %myword% to the types.or= filter, you need to do this:

/suppliers?select=code,name,types(*)&types.or=(label.ilike.*myword*,description.ilike.*myword*)&or=(code.ilike.*myword*,types.not.is.null)

We added &or=(code.ilike.*myword*,types.not.is.null). This means that PostgREST will get all the suppliers that have code.ilike.*myword* OR those where the embedded types is not null, that …

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@joachimlucas
Comment options

@joachimlucas
Comment options

@laurenceisla
Comment options

Answer selected by laurenceisla
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants