Ariel
Ariel
Explore posts from servers
DTDrizzle Team
Created by Ariel on 1/30/2024 in #help
Lateral Left Joins in Drizzle Core Queries
I am creating a more complex Postgres query that requires me to drop down to the sql abstractions of drizzle (my query needs to use window functions and group bys). In this same query, I would like to return a column that includes a list of relations, ideally as a JSON array. My initial instinct was to try to recreate the lateral left join query, similar to how the drizzle query builder returns relations using the with option. However, in my reading of the documentation and the code, it doesn't appear that there is a way to access lateral left joins using the db.select()... syntax. Reading through the code, it doesn't seem like the lateral option is exposed as part of a public API. I expect I might be able to write a subquery or a CTE in order to achieve this goal, but I was wondering whether there was anything I was missing/any way I could more easily replicate how drizzle achieves this goal? Thanks!
5 replies