Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions src/main/scala/slick/examples/codegen/Example.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,25 @@ import scala.language.postfixOps
import slick.examples.codegen.Tables.*
import slick.examples.codegen.Tables.profile.api.*

object Example extends App {
object Example {
// connection info for a pre-populated throw-away, in-memory db for this demo, which is freshly initialized on every
// run
val url = "jdbc:h2:mem:test;INIT=runscript from 'src/main/sql/create.sql'"
val db = Database.forURL(url, driver = "org.h2.Driver")

// Using generated code. Our Build.sbt makes sure they are generated before compilation.
val q = Companies
.join(Computers)
.on(_.id === _.manufacturerId)
.map { case (co, cp) => (co.name, cp.name) }

Await.result(
db.run(q.result).map { result =>
println(result.groupMap(_._1)(_._2).mkString("\n"))
},
60 seconds
)

def main(args: Array[String]): Unit = {
val db = Database.forURL(url, driver = "org.h2.Driver")

// Using generated code. Our Build.sbt makes sure they are generated before compilation.
val q = Companies
.join(Computers)
.on(_.id === _.manufacturerId)
.map { case (co, cp) => (co.name, cp.name) }

Await.result(
db.run(q.result).map { result =>
println(result.groupMap(_._1)(_._2).mkString("\n"))
},
60 seconds
)
}
}
Loading