Creating a jsonAgg helper funtcion that returns a context aware `AggregateFunctionBuilder`
Greetings. I am wondering if it's possible to create a helper that does exactly what
- I have tried using the
- I have tried creating a simple helper, but it's not type/context aware, and it doesn't support method chaining (
- Lastly, I have tried recreating the
Example of the problem demonstrated: https://kyse.link/7zHaq
---
I have since refactored my code, but this might not always be an easy option in the future, so I was curious to know if there is a way around this problem.
eb.fn.jsonAgg does but for JSONB.- I have tried using the
helpers/postgres/jsonArrayFrom, but that is functionally not the same because it creates a subquery.- I have tried creating a simple helper, but it's not type/context aware, and it doesn't support method chaining (
.distinct() for example):- Lastly, I have tried recreating the
jsonAgg function from the source code and that almost works, however it's not aware of the query context, and you can for example aggregate on a completely unrelated table, since it uses the entire DB type as first generic parameter (<DB extends MyDB, TB extends keyof DB....>Example of the problem demonstrated: https://kyse.link/7zHaq
---
I have since refactored my code, but this might not always be an easy option in the future, so I was curious to know if there is a way around this problem.