Repo

zio.blocks.sql.Repo
See theRepo companion class
object Repo

Attributes

Companion
class
Source
Repo.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Repo.type

Members list

Value members

Concrete methods

def apply[E, ID](table: Table[E], idColumn: String, idCodec: DbCodec[ID], getId: E => ID): Repo[E, ID]

Constructs a Repo from explicit components.

Constructs a Repo from explicit components.

Attributes

Source
Repo.scala
def derived[E, ID](idColumn: String, getId: E => ID)(using schema: Schema[E], idCodec: DbCodec[ID]): Repo[E, ID]

Derives a Repo from E's schema with a caller-supplied ID column name and getter. The table name is derived from the schema type name using the default singular snake_case policy.

Derives a Repo from E's schema with a caller-supplied ID column name and getter. The table name is derived from the schema type name using the default singular snake_case policy.

Attributes

Source
Repo.scala
def derived[E, ID](tableName: String, idColumn: String, getId: E => ID)(using schema: Schema[E], idCodec: DbCodec[ID]): Repo[E, ID]

Derives a Repo from E's schema with an explicit table name, caller- supplied ID column name, and getter.

Derives a Repo from E's schema with an explicit table name, caller- supplied ID column name, and getter.

Attributes

Source
Repo.scala
def derived[E, ID](using schema: Schema[E], idSchema: Schema[ID], idCodec: DbCodec[ID]): Repo[E, ID]

Fully auto-derives a Repo by inspecting E's schema to locate the ID field using a 4-priority rule:

Fully auto-derives a Repo by inspecting E's schema to locate the ID field using a 4-priority rule:

  1. @Modifier.id annotation on a field whose type matches ID
  2. Unique field whose type matches ID (previously the only strategy)
  3. Field literally named "id" whose type matches ID
  4. Field named Id (e.g. userId for entity User) whose type matches ID

The ID column name respects @Modifier.rename annotations; the table name uses the default naming policy.

Fails at runtime with IllegalArgumentException if:

  • E is not a record (case class)
  • No field can be resolved by any of the four strategies
  • Multiple fields match the same priority (ambiguous @Modifier.id)

Attributes

Source
Repo.scala