문제

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top