I am trying to figure out Slick (Scala functional relational model). I started creating a prototype in Slick 3.0.0, but of course ... most of the documentation is either outdated or incomplete.
I managed to get to the point where I can create the schema and return the object from the database.
The problem is that I am returning - this is "Rep [Bind]" and not the object I would expect to receive. I canβt understand what to do for this. For example, if I try something like rep.countDistinct.result, I get a crash.
Here is a quick overview of the code ... some are removed for brevity:
class UserModel(tag: Tag) extends Table[User](tag, "app_dat_user_t") { def id = column[Long]("n_user_id", O.PrimaryKey) def created = column[Long]("d_timestamp_created") def * = (id.?, created) <> (User.tupled, User.unapply) } case class User(id: Option[Long], created: Long) val users = TableQuery[UserModel] (users.schema).create db.run(users += User(Option(1), 2)) println("ID is ... " + users.map(_.id)) // prints "Rep[Bind]"... huh? val users = for (user <- users) yield user println(users.map(_.id).toString) // Also prints "Rep[Bind]"...
I cannot find a way to βexpandβ the Rep object, and I cannot find a clear explanation of what it is or how to use it.
source share