id |name |
-----|---------|
1 |example1 |
2 |example2 |
Of course I've mapped classes through orm.
I want to select all records from a join b and then group by a object and aggregate all related records from b to an array of b objects:
( <model.TableA>, [<model.TableB>, <model.TableB>] )
So far I only found a solution of using some mix of postgresql dialect and sa
like:
postgresql.array_agg(func.json_build_object("id", TableB.id, "name", TableB.name))
and I can produce
( <model.TableA>, [{"id":1, "name": "example1"}, {"id":2, "name": "example2"}] )
but ideally would by the array of objects