Filtering findMany using related records
I have a
restaurants
table that has a one-to-one relation with an addresses
table. I want to pull all of the restaurants and their address within specific lat/long bounds, but I'm struggling to figure out how to do that. A simplified version of what I want/have so far
I'm trying to figure out if this is somethin Drizzle can do or if I need to break into using sql`` to do it10 Replies
if you need to filter by address I guess you need to write this where inside address
didn't check in idea
just typed here
if I got you right ofc
wouldn't this still return all restaurants, but only return the address for those that satisfy the bounds?
oh, you are right. In you need to query by relations I guess it's not possible yet, so you need to write where statement as
sql
we have only an example for size
https://orm.drizzle.team/docs/rqb#select-filters
and not for more complex queries
I guess for this case you can use core api + aggregation like this
https://orm.drizzle.team/docs/joins#aggregating-resultsi’d really appreciate some more complex examples (as i imagine OP would). i’ve been trying to figure it out in my thread
sorry, was a bit busy to get through all threads
that’s ok
we will get more examples in docs for such cases
sure
whenever you have time i’d love that thanks
Thanks @Andrew Sherman ! Do you think that filtering like this would come to the RQB at any point? Does it seem like a valid use-case for Drizzle?
is this in the docs somewhere now btw?