-
Notifications
You must be signed in to change notification settings - Fork 186
Data modelling
Flavian Alexandru edited this page May 30, 2016
·
2 revisions
import java.util.Date
import com.websudos.phantom.sample.ExampleModel
import com.websudos.phantom.dsl._
case class ExampleModel (
id: Int,
name: String,
props: Map[String, String],
timestamp: Int,
test: Option[Int]
)
sealed class ExampleRecord extends CassandraTable[ExampleRecord, ExampleModel] {
object id extends UUIDColumn(this) with PartitionKey[UUID]
object timestamp extends DateTimeColumn(this) with ClusteringOrder[DateTime] with Ascending
object name extends StringColumn(this)
object props extends MapColumn[ExampleRecord, ExampleModel, String, String](this)
object test extends OptionalIntColumn(this)
def fromRow(row: Row): ExampleModel = {
ExampleModel(id(row), name(row), props(row), timestamp(row), test(row));
}
}
To stay up-to-date with our latest releases and news, follow us on Twitter: @outworkers.
- Issues and questions
- Adopters
- Roadmap
- Changelog
- Tutorials
- Commercial support
- Using phantom in your project
- Primitive columns
- Optional primitive columns
- Collection columns
- Collection operators
- Automated schema generation
- Indexing columns
- Data modeling with phantom
- Querying with phantom
- Asynchronous iterators
- Batch statements
- Apache Thrift integration
- Apache ZooKeeper integration
- The phantom testkit