/zio-cassandra

Just alternative wrapper for zio, inspired by akka(alpakka)-cassandra

Primary LanguageScalaApache License 2.0Apache-2.0

Release Artifacts Snapshot Artifacts

zio-cassandra

scala = 2.13.6
cassandra-driver = 4.13.0
zio = 1.0.12

Inspired by akka/alpakka-cassandra

Usage

Dependency:

libraryDependencies += "io.github.jsfwa" %% "zio-cassandra" % "1.0.6"

Check driver config documentation on datastax

// Cassandra Session:
  val session = CassandraSession.make(config)
//OR
  val session = CassandraSession.make(cqlSessionBuilder)

// Use:
  val job = for {
    session  <- ZIO.service[CassandraSession]
    _        <- session.execute("insert ...")
    prepared <- session.prepare("select ...")
    select   <- session.bind(prepared, Seq(args))
    row      <- session.selectOne(select, profileName = "oltp")
  } yield row
  
  job.provideCustomLayer(CassandraSession.make(config).toLayer)