Open alexflav23 opened 6 years ago
@hsn10 I know you had thoughts here, please feel free to add to the mix.
I need ability to override column type including column used for primary key
The code below is how I implemented table inheritance to change PartitionKey and ClusteringOrder setting on different table.
import com.outworkers.phantom.dsl._
case class User(userId: String,
gender: Int,
birthDate: DateTime)
trait UserTable[Owner <: Table[Owner, User] with UserTable[Owner]] extends Table[Owner, User] {
def name: StringColumn
def gender: IntColumn
def birthDate: DateTimeColumn
// def query(): Future[ListResult[User]]
}
abstract class UserByGender extends UserTable[UserByGender] {
object name extends StringColumn
object birthDate extends DateTimeColumn
object gender extends IntColumn with PartitionKey
}
abstract class UserByBirthDate extends UserTable[UserByBirthDate] {
object name extends StringColumn
object gender extends IntColumn
object birthDate extends DateTimeColumn with ClusteringOrder with Descending
}
As requested by multiple users, we should natively support table inheritance as many applications seem to require it as a simplification of the DSL code, instead of trying to discourage it.
Draft proposal.