I want to filter rows by column which I don't want to see in my domain class. So for example my table looks like this:
class UserTable(tag: Tag) extends Table[(Int, String, Boolean)](tag, "users") {
def id = column[Int]("id")
def name = column[String]("name")
def active = column[Boolean]("active")
override def * = (id, name, active)
}
And my domain class like this:
case class User(id: Int, name: String)
For some reason I don't want to have filed active
in my User
class. But I want to have queries which produces User
as a result. And I don't want to map futures. Like this:
val activeUsers: Future[Seq[User]] = db.run(query.filter(_.active === true) /* how to convert it here? */)
So my problem could be solved in two ways. Define UserTable
like UserTable[User]
and still somehow filter it by active
column. Or define UserTable
as it defined now and convert tuples to User
class. I almost sure that the first one is not possible, but the second one should be possible. How to do this?