Moose
Moose
DTDrizzle Team
Created by Moose on 12/4/2023 in #help
Help with refactoring a (probably unnecessarily) huge query
idk what's funny about that, this is way more complex than just writing raw sql lmao
44 replies
DTDrizzle Team
Created by Moose on 12/4/2023 in #help
Help with refactoring a (probably unnecessarily) huge query
i don't understand this 🤔 i'm new to json functionality in postgres so not sure why it's giving me an error like this for every column now. PostgresError: column "top_posts.id" must appear in the GROUP BY clause or be used in an aggregate function
44 replies
DTDrizzle Team
Created by Moose on 12/4/2023 in #help
Help with refactoring a (probably unnecessarily) huge query
at this point i'm gonna revert lol
44 replies
DTDrizzle Team
Created by Moose on 12/4/2023 in #help
Help with refactoring a (probably unnecessarily) huge query
anyways, since i added the media json_agg it's now making me add *every *column as an entry to .groupBy, which i'm sure will not produce the intended result. sorry for being difficult 🤣
44 replies
DTDrizzle Team
Created by Moose on 12/4/2023 in #help
Help with refactoring a (probably unnecessarily) huge query
not following... we're selecting top 10 from posts, and media that belongs to those posts, hence the join
44 replies
DTDrizzle Team
Created by Moose on 12/4/2023 in #help
Help with refactoring a (probably unnecessarily) huge query
oh right i can just use where i guess
44 replies
DTDrizzle Team
Created by Moose on 12/4/2023 in #help
Help with refactoring a (probably unnecessarily) huge query
😮 how could it not be?
44 replies
DTDrizzle Team
Created by Moose on 12/4/2023 in #help
Help with refactoring a (probably unnecessarily) huge query
when i was doing the raw sql i was ordering like this: .orderBy(({ createdAt, media }) => [desc(createdAt), asc(media.url)])
44 replies
DTDrizzle Team
Created by Moose on 12/4/2023 in #help
Help with refactoring a (probably unnecessarily) huge query
i'll try just ordering it in the subquery
44 replies
DTDrizzle Team
Created by Moose on 12/4/2023 in #help
Help with refactoring a (probably unnecessarily) huge query
also, tysm for spending time on this! 🫡
44 replies
DTDrizzle Team
Created by Moose on 12/4/2023 in #help
Help with refactoring a (probably unnecessarily) huge query
are we able to order that?
44 replies
DTDrizzle Team
Created by Moose on 12/4/2023 in #help
Help with refactoring a (probably unnecessarily) huge query
ah yeah that makes sense, since i was doing that manually before
44 replies
DTDrizzle Team
Created by Moose on 12/4/2023 in #help
Help with refactoring a (probably unnecessarily) huge query
it's producing an object matching the 'selectObj' variable which i guess is obvious, and it's getting one media object with id and url. problem is i want it to produce an array of media objects
44 replies
DTDrizzle Team
Created by Moose on 12/4/2023 in #help
Help with refactoring a (probably unnecessarily) huge query
it's essentially a mirror of what i had written initially in sql at this point
44 replies
DTDrizzle Team
Created by Moose on 12/4/2023 in #help
Help with refactoring a (probably unnecessarily) huge query
i don't understand 🤔
44 replies
DTDrizzle Team
Created by Moose on 12/4/2023 in #help
Help with refactoring a (probably unnecessarily) huge query
almost there! I currently have an issue with media, it's only pulling through a single object. not sure how to get it to pull through an array of the related media. any tips or ideas on further refactoring?
44 replies
DTDrizzle Team
Created by Moose on 12/4/2023 in #help
Help with refactoring a (probably unnecessarily) huge query
so the new stuff should cover it then?
44 replies
DTDrizzle Team
Created by Moose on 12/4/2023 in #help
Help with refactoring a (probably unnecessarily) huge query
They didn't have union support until recently
44 replies
DTDrizzle Team
Created by Moose on 12/4/2023 in #help
Help with refactoring a (probably unnecessarily) huge query
i'm sorry for creating this abomination...
44 replies