scala - How to model enum types in phantom dsl? -
my case class contains enum parameter follows:
case class user(role: userrole.userrole, name: string) object userrole extends enumeration { type userrole = value val admin, user = value }
how model case in example: https://github.com/thiagoandrade6/cassandra-phantom/blob/master/src/main/scala/com/cassandra/phantom/modeling/model/genericsongsmodel.scala ?
any code samples provided helpful.
you need use enumcolumn
, created reason. if want use enum key, need create primitive using default helper methods.
you can use both flavours of defining enum.
object records extends enumeration { type records = value val typeone, typetwo, typethree = value } object namedrecords extends enumeration { type namedrecords = value val 1 = value("one") val 2 = value("two") } object enum extends enumcolumn[records.type](this, records)
in case be:
object role extends enumcolumn[userrole.type](this, userrole)
to use index, need:
implicit val userroleprimitive = primitive(userrole)
update of phantom 2.0.0+
object role extends enumcolumn[userrole](this)
you don't need define additional implicits, enums natively suported indexes.
Comments
Post a Comment