Composite
doobie.Composite$
object Composite
Attributes
- Source
- Composite.scala
- Graph
-
- Supertypes
- Self type
-
Composite.type
Members list
Value members
Concrete methods
def apply[T <: Tuple : IsMappedBy[SQLDefinition], R](sqlDefinitionsTuple: T)(map: InverseMap[T, SQLDefinition] => R)(unmap: R => InverseMap[T, SQLDefinition]): SQLDefinition[R]
Allows you to define a composite type that is composed of other SQLDefinitions.
Allows you to define a composite type that is composed of other SQLDefinitions.
For example you can compose multiple Columns:
case class Person(name: String, age: Int)
val nameCol = Column[String]("name")
val ageCol = Column[Int]("age")
val person: SQLDefinition[Person] =
Composite((nameCol.sqlDef, ageCol.sqlDef))(Person.apply)(Tuple.fromProductTyped)
// or alternatively
val person: SQLDefinition[Person] =
Composite((nameCol, ageCol).toSqlResults)(Person.apply)(Tuple.fromProductTyped)
Or even other Composites:
val pet1Col = Column[String]("pet1")
val pet2Col = Column[String]("pet2")
case class Pets(pet1: String, pet2: String)
val pets: SQLDefinition[Pets] = Composite((pet1Col.sqlDef, pet2Col.sqlDef))(Pets.apply)(Tuple.fromProductTyped)
case class PersonWithPets(person: Person, pets: Pets)
val personWithPets: SQLDefinition[PersonWithPets] =
Composite((person, pets))(PersonWithPets.apply)(Tuple.fromProductTyped)
Value parameters
- map
-
Function to map the tuple of components to the final result
- sqlDefinitionsTuple
-
Tuple of SQLDefinitions to compose
- unmap
-
Function to map the final result to the tuple of components
Attributes
- Source
- Composite.scala
Overload for a single element tuple.
In this article