私は playframework で Slick (および Scala) から始めています。私のプロジェクトは、ドメイン コンセプトのすべてのクラスとオブジェクトを含む .scala ファイルで構成されています。
package models
class Folder(val id: Option[Long], var name: String, val childrens:Set)
object Folder{
val folders = new db.Folders
def get(id: Long)(implicit s: Session): Option[Folder] = {
Query(users).where(_.id === id).firstOption.map { r: db.Row =>
new Folder(r.id, r.name, Set.empty]) // TODO load childrens for folder
}
}
}
// Attempt to segregate and maybe restrict the persistence code
package db {
case class Row(id: Option[Long], name: String)
class Folders extends Table[Row]("folders") {
def id = column[Long]("id", O.PrimaryKey, O.AutoInc)
def name = column[String]("name", O.NotNull)
def * = id.? ~ name <> (map _, unmap _)
// ...
}
}
Folder
内部パッケージの可視性をオブジェクトのみに制限できる Scala コンストラクトはありますか?
ありがとう