DbCodec

zio.blocks.sql.DbCodec
See theDbCodec companion object
trait DbCodec[A]

Bidirectional codec between a Scala value A and one or more database columns.

Column ordering matches the columns IndexedSeq. The startIndex parameter in positional readValue / writeValue is 1-based (JDBC convention): column 1 corresponds to columns(0). Query decoding prefers the label-based overload so result column order can differ from codec order as long as column labels still match.

Attributes

Companion
object
Source
DbCodec.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

def columns: IndexedSeq[String]

Attributes

Source
DbCodec.scala
def readValue(reader: DbResultReader, columnLabels: IndexedSeq[String]): A

Attributes

Source
DbCodec.scala
def toDbValues(value: A): IndexedSeq[DbValue]

Attributes

Source
DbCodec.scala
def writeValue(writer: DbParamWriter, startIndex: Int, value: A): Unit

Attributes

Source
DbCodec.scala

Concrete methods

def columnCount: Int

Attributes

Source
DbCodec.scala
def readValue(reader: DbResultReader, startIndex: Int): A

Attributes

Source
DbCodec.scala
final def transform[B](read: A => B)(write: B => A): DbCodec[B]

Returns a new DbCodec[B] by mapping read values with read and write values with write. Both functions are total; exceptions propagate as-is. Use this to create codecs for opaque types and value wrappers without defining a full Schema.

Returns a new DbCodec[B] by mapping read values with read and write values with write. Both functions are total; exceptions propagate as-is. Use this to create codecs for opaque types and value wrappers without defining a full Schema.

Attributes

Source
DbCodec.scala