· 8 years ago · Feb 20, 2018, 09:00 PM
1import com.outworkers.phantom.builder.primitives.Primitive
2import com.outworkers.phantom.dsl._
3
4abstract class DST[V, P <: TSP[V], T <: DST[V, P, T]] extends Table[T, P] {
5 object entityKey extends StringColumn with PartitionKey {
6 override lazy val name = "entity_key"
7 }
8
9 abstract class entityValue(implicit ev: Primitive[V]) extends PrimitiveColumn[V] {
10 override lazy val name = "entity_value"
11 }
12
13abstract class SDST[P <: TSP[String]] extends DST[String, P, SDST[P]] {
14 override def tableName: String = ""SDS""
15
16 object entityValue extends entityValue
17}
18
19class TestDatabase(override val connector: CassandraConnection) extends Database[TestDatabase](connector) {
20object SDST extends SDST[SDSR] with connector.Connector {
21 override def fromRow(r: Row): SDSR=
22 SDSR(entityKey(r), entityValue(r))
23 }
24}
25
26c.o.phantom Executing query: CREATE TABLE IF NOT EXISTS test."SDS" (entity_key text,PRIMARY KEY (entity_key))