I'm beginning with slick and scala, using playframewok
I have configured my project to work with play 2.2.0 using play-slick 0.5.0.8
My problem is that I can't execute some essential methods like "list , foreach, for{}yield ..."
I have tried a stand alone example and it works with the same slick version 1.0.1??
Here is the project build file
import sbt._
import Keys._
import play.Project._
object Build extends Build {
val appName = "homePage"
val appVersion = "1.0-ALPHA"
val appDependencies = Seq(
// Add your project dependencies here,
jdbc,
"com.typesafe.play" %% "play-slick" % "0.5.0.8" ,
"postgresql" % "postgresql" % "9.1-901-1.jdbc4",
"com.typesafe.slick" %% "slick" % "1.0.1"
)
val main = play.Project(appName, appVersion, appDependencies).settings(
// add web app as
playAssetsDirectories <+= baseDirectory / "webapp"
)
}
package model
import java.util.Calendar
import scala.slick.driver.PostgresDriver.simple._
case class Article(id: Long,
content: String,
date: java.sql.Date)
object Articles extends Table[Article]("articles") {
def id = column[Long]("art_id", O.PrimaryKey , O.AutoInc) // This is the primary key column
def content = column[String]("art_content", O.NotNull)
def date = column[java.sql.Date]("art_date", O.NotNull, O.Default(new java.sql.Date(Calendar.getInstance().getTime.getTime)))
def * = id ~ content ~ date <> (Article.apply _, Article.unapply _)
}
here is the code that doesn't work
query foreach { case (content, date) =>
println(" " + name + ": " + count)
}
//:: cannot resolve the symbol foreach
same thing for [for , yield]
(for(p <- Props if p.key === k) yield p.value).firstOption
I don't know what is the problem, so every help will be appreciated.
import scala.slick.driver.PostgresDriver.simple._
in the file, where you try to call foreach.
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