bambam22
bambam22
DTDrizzle Team
Created by bambam22 on 12/27/2023 in #help
Is it possible to pass sub query to `from`?
I have a db.select().from() and I need to pass a nested query into that from.
SELECT g.id, g.name, g.background_image, json_agg(p) as platforms
FROM (
SELECT g.*
FROM games g
JOIN games_to_platforms gtp on gtp.game_id = g.id
JOIN platforms p on gtp.platform_id = p.id
WHERE p.slug = 'pc'
) as g
SELECT g.id, g.name, g.background_image, json_agg(p) as platforms
FROM (
SELECT g.*
FROM games g
JOIN games_to_platforms gtp on gtp.game_id = g.id
JOIN platforms p on gtp.platform_id = p.id
WHERE p.slug = 'pc'
) as g
7 replies
DTDrizzle Team
Created by bambam22 on 12/27/2023 in #help
Use `getTableColumns` with `groupBy`
I am doing a nested query and postgres is requiring that every column I select be in the group by, can I use the method getTableColumns in the groupBy, I've tried just calling the method and destructing. No luck, the error reads "must have a Symbol.iterator method that returns an iterator"
3 replies
DTDrizzle Team
Created by bambam22 on 11/26/2023 in #help
Map casing when using sql`` operator
If I query my table using the magic sql operator. How can I get back the column names like userId instad of how they are in the tabel user_id?
61 replies