I'm following guidelines of Slick documentation and I don't understand what I'm doing wrong here:
package models
import scala.slick.session.Database
import Database.threadLocalSession
import scala.slick.jdbc.{GetResult, StaticQuery => Q}
import javax.sql.DataSource
import Q.interpolation
object Data {
case class User(user: String, password: String)
lazy val db = Database.forName("default")
def result: Option[User] = {
db.withSession {
sql"SELECT user, password FROM user WHERE user = 'user' AND password = 'pass'".as[User]
}
}
}
The line
sql"SELECT user, password FROM user WHERE user = 'user' AND password = 'pass'".as[User]
is giving me this:
Multiple markers at this line
- could not find implicit value for parameter rconv: scala.slick.jdbc.GetResult[models.Data.User]
- could not find implicit value for parameter rconv: scala.slick.jdbc.GetResult[models.Data.User]
What am I doing wrong here?
Play Framework 2.2.0, Scala 2.10.3, Slick 1.0.1
You need to provide the conversion function from result to user. Copied and adapted straight from the slick home:
implicit val getUserResult = GetResult(r => User(r.<<, r.<<))
Or this section from the documentation you linked
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With