scala - Slick select all rows for table with no filtering -
how can collection of jurisdictionrow
objects? need select * jurisdiction
object jurisdictionrepo extends { val profile = slick.driver.mysqldriver } jurisdictionrepo trait jurisdictionrepo { private val dbconfig: databaseconfig[mysqldriver] = databaseconfig.forconfig("pnga-master-data") private val db = dbconfig.db val profile: slick.driver.jdbcprofile val tablename = "jurisdiction" def add(jurisdictionrow: jurisdictionrow): future[unit] = db.run(query += jurisdictionrow).map { _ => () } def delete(id: string): future[int] = db.run(query.filter(_.id === id).delete) def get(id: string): future[option[jurisdictionrow]] = db.run(query.filter(_.id === id).result.headoption) def all() = ??? import profile.api._ lazy val schema: profile.schemadescription = query.schema case class jurisdictionrow(id: string, parentid: string, name: string, code: string) class jurisdiction(_tabletag: tag) extends table[jurisdictionrow](_tabletag, tablename) { val id: rep[string] = column[string](s"${tablename}_id", o.primarykey, o.length(36, varying=true)) val parentid: rep[string] = column[string]("parent_id", o.length(36, varying=true)) val name: rep[string] = column[string]("name", o.length(255, varying=true)) val code: rep[string] = column[string]("code", o.length(255, varying=true)) def * = (id, parentid, name, code) <> (jurisdictionrow.tupled, jurisdictionrow.unapply _) } lazy val query = new tablequery(tag => new jurisdiction(tag)) }
i implement all
method return possible jurisdictionrow
objects in table. seems common case, slick documentation has not been helpful. need plain old result set, no fancy filtering, etc.
just replicate have in other queries without filter part.
def = db.run(query.result)
have @ first example: http://slick.lightbend.com/doc/3.2.0/gettingstarted.html#querying
Comments
Post a Comment