This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.outworkers.phantom.dsl._ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.outworkers.phantom.dsl._ | |
object Defaults { | |
val Connector = ContactPoint.local.keySpace(KeySpace("my_keyspace") | |
.ifNotExists().`with`(replication eqs SimpleStategy.replication_factor(1))) | |
} | |
class CassandraDatabase(override val connector: CassandraConnection) extends Database[CassandraDatabase](connector) { | |
object users extends Users with Connector | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class User( | |
id: String, | |
email: Set[String], | |
name: String | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.outworkers.phantom.dsl._ | |
abstract class Users extends Table[Users, User] { | |
object id extends StringColumn with PartitionKey | |
object email extends SetColumn[String] | |
object name extends StringColumn with PartitionKey | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Table[T <: Table[T, R], R] extends CassandraTable[T, R] with TableAliases[T, R] with RootConnector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.outworkers.phantom.connectors | |
trait RootConnector extends scala.AnyRef { | |
implicit def space : com.outworkers.phantom.connectors.KeySpace | |
implicit def session : com.datastax.driver.core.Session | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def save(user: User): Future[ResultSet] = { | |
insert | |
.value(_.id, user.id) | |
.value(_.name, user.name) | |
.value(_.email, user.email) | |
.future() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getAllUsers: Future[List[User]] = { | |
select | |
.fetch() | |
} | |
def getByid(id: String): Future[Option[String]] = { | |
select(_.name) | |
.where(_.id eqs id) | |
.allowFiltering() | |
.one() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependencies> | |
<dependency> | |
<groupId>io.vavr</groupId> | |
<artifactId>vavr</artifactId> | |
<version>0.9.0</version> | |
</dependency> | |
</dependencies> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<String> list = List.of("Java", "PHP", "Jquery", "JavaScript", "JShell", "JAVA"); |