Closed nicholasgriffintn closed 1 year ago
Those don't actually create joins but subqueries. But I'm guessing by joins, you mean fetching related items as nested objects/lists? Probably the easiest way to do that conditionally is to use the $if
method: https://kyse.link/?p=s&i=oveFTLrzoDsQFAqRrD4O
There's a recipe on the subject https://kysely.dev/docs/recipes/conditional-selects.
Ahhh I see! That makes sense thanks :)
Hey,
I've found the docs on relations that suggest to do joins like this:
I'm wondering, what would be the best way to do the joins conditionally?
Basically, I only want to join X if the matching param is provided. Sorry if that's super simple and I've missed it in the docs somewhere :)