2016-03-07 19 views
0

我的情況下,類找不到匹配的形狀。油滑不知道如何映射給定類型

case class Entry(id: Int, title: String, content: String, 
           publishedDate: Date, views: Int) 

的Schena

class Entries(tag: Tag) extends Table[Entry](tag, "ENTRIES") { 
     def id = column[Int]("id", O.PrimaryKey, O.AutoInc) 
     def title = column[String]("title") 
     def content = column[String]("content") 
     def publishedDate = column[Date]("published_date") 
     def views = column[Int]("views") 

     override def * = (id, title, content, publishedDate, views) <> (Entry.tupled, Entry.unapply) 
    } 

val entries = TableQuery[Entries] 

我的查詢:

def byId(id: Rep[Int]) = for (entry <- entries if entry.id === id) yield entry.first 
val entryById = Compiled(byId _) 
def get(id: Int): Option[Entry] = db.Schema.entryById(id).result.run(DB) 

當我跑我得到這個錯誤:沒有找到匹配的形狀。斯利克不知道 如何映射給定的類型。

播放:2.4 斯卡拉:2.11.6 油滑:3.1.1

編輯:我也得到了「價值首先是不db.Schema.Entries的成員」和「一個類似的錯誤結果「

回答

1

方法firstfistOption在slick 3.0.0中刪除。使用headheadOption

相關問題