K
Kysely•2d ago
Raizel

I need to extract the type of eb in the query chain

I have a complex query (more than 800 lines). Its mostly json formatting. Is there a way I can extract out the type of eb so for each nested json object I build, I can create a helper method. Or is this not possible. Also, is it an anti pattern to do the json formatting in the query iteself ?
5 Replies
Igal
Igal•2d ago
Hey 👋 Provide a kyse.link. Can't help you otherwise.
Raizel
RaizelOP•20h ago
Hello, https://kyse.link/SBDmw Here is the link in the query you see various json objects being constructed. What I would like to do is extract each of that into a separate helper function but for that I need the type of eb to maintain type-safety and I can't seem to find a way for that
Igal
Igal•20h ago
Seems like jsonObjectFrom would simplify this a lot.
Raizel
RaizelOP•20h ago
Okay, looking into this I'm still a bit confused. Wouldn't the jsonObjectFrom method still require eb Would be very helpful if you can share a sample snippet
Igal
Igal•19h ago
it'd remove a bunch of left joins. instead you'll have a base query that's slimmer. and the related json stuff will be contained in the select. allowing you to extract it. under the hood the database's optimizer might still perform left joins.

Did you find this page helpful?