Scala Enumerations (case objects) in Slick, good practice
问题 Suppose I have a trait representing a set of several valid states. Would it be a good practice to store the objects in the database? Would it be better to store Ints and map them to DoorState with an implicit function MappedColumnType.base[Int, DoorState]? trait DoorState case object Open extends DoorState case object Closed extends DoorState class Doors(tag: Tag) extends Table[Door](tag, "DOORS") { ... def state = column[DoorState]("DOOR_STATE") ... } 回答1: Recommendation from the makers use: