You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
what is the easiest way to decode joined rows? select s.*, c.* from services s inner join catalogs c on s.catalog_id=c.id
I tried to decode it to case class ServiceWithDetails(service: Service, catalog: Catalog)
, but did not succeed. No, actually I did it with map and manually filled ServiceWithDetails class and inner Service and Catalog , but it is so ugly looking after using slick that I thought there was a more elegant way to do it.
one way i found is convert table data to json in select statement: select to_json(s.*), to_json(c.*) from services s inner join catalogs c on s.catalog_id=c.id
and decode it (json[Service] *: json[Catalog]).to[ServiceWithDetails]
that works but with one little problem. the fields of case classes have to be in snake case to properly map.
This example is very simple. In general i have 3-10 table joins and map manually (fill every field of case class) seems hard and a waste of time.
Are there other methods?
The text was updated successfully, but these errors were encountered:
what is the easiest way to decode joined rows?
select s.*, c.* from services s inner join catalogs c on s.catalog_id=c.id
I tried to decode it to
case class ServiceWithDetails(service: Service, catalog: Catalog)
, but did not succeed. No, actually I did it with map and manually filled ServiceWithDetails class and inner Service and Catalog , but it is so ugly looking after using slick that I thought there was a more elegant way to do it.
one way i found is convert table data to json in select statement:
select to_json(s.*), to_json(c.*) from services s inner join catalogs c on s.catalog_id=c.id
and decode it
(json[Service] *: json[Catalog]).to[ServiceWithDetails]
that works but with one little problem. the fields of case classes have to be in snake case to properly map.
This example is very simple. In general i have 3-10 table joins and map manually (fill every field of case class) seems hard and a waste of time.
Are there other methods?
The text was updated successfully, but these errors were encountered: