When I do a query using Scala Slick I then need to map the results to access them and flatten them into a (). The problem here is that the joins produce many _._1._2._3._1 etc. Is there a better way to do this?
Events.events.filter( (i: Events) => {
((i.isGhost === true) && (i.ghostOfEventId === groupId)) ||
((i.isGhost === false) && (i.id === groupId))
})
.join(ProfileEvents.profileEvents).on(_.id === _.eventId)
.join(Profiles.profiles).on(_._2.profileId === _.id)
.join(ProfileEx1s.profileEx1s).on(_._2.id === _.profileId)
.run.toList.map( (n) => {
(n._1._1._1, // Event
n._1._1._2, // ProfileEvent
n._1._2, // Profile
n._2) // ProfileEx1s
})
You can do this with a for-comprehension:
I probably mixed up the join conditions, but you should get the idea behind.