slick / slick-examples

A sample project for getting started with Slick
https://scala-slick.org/
156 stars 70 forks source link

Embedding example would be helpful #4

Open mslinn opened 11 years ago

mslinn commented 11 years ago

How about an example along these lines?

    @table("COFFEES") case class Coffee(
    @column("COF_NAME") name: String,
    @column("SUP_ID") supID: Int,
    @column("PRICE") price: Double
    )
    val coffees = Queryable[Coffee]

    // for inserts use lifted embedding or SQL

    val l = for {
    c <- coffees if c.supID == 101
    // ^ comparing Int to Int!
    } yield (c.name, c.price)

    backend.result( l, session )
    .foreach { case (n, p) => println(n + ": " + p) }
szeiger commented 11 years ago

Agreed. Assigning Chris to this.