I am trying to apply .groupBy
in a Slick query
var q = (for {
user <- Users
userSettings <- UserSettings if user.id === userSettings.userId
} yield (user, userSettings)).groupBy {
case (users, userSettings) =>
(user.id, userSettings.controls)
}.map {
case (x, y) => (x._1, y.map(_._2.controls).???)
}
If the controls
column was an Integer or Long, I could apply sum
, avg
and other aggregate functions. But in this case controls
is a string. How to group concatenate these strings so that records look like
-----------------------------------------
|User ID |User Controls |
-----------------------------------------
|1 |left, right, up, down |
|2 |left, right |
-----------------------------------------
without applying groupBy
records look like this
-----------------------------------------
|User ID |User Controls |
-----------------------------------------
|1 |left |
|1 |right |
|1 |up |
|1 |down |
|2 |left |
|2 |right |
-----------------------------------------