Composite

doobie.Composite
object Composite

Attributes

Source
Composite.scala
Graph
Supertypes
class Object
trait Matchable
class Any
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
def apply[A, R](sqlDefinition: SQLDefinition[A])(map: A => R)(unmap: R => A): SQLDefinition[R]

Overload for a single element tuple.

Overload for a single element tuple.

Attributes

Source
Composite.scala
def fromMultiOption[A1, A2, R](a1Def: SQLDefinition[Option[A1]], a2Def: SQLDefinition[Option[A2]])(map: (A1, A2) => R)(unmap: R => (A1, A2)): SQLDefinition[Option[R]]

SQLDefinition when the element is defined by two Optional values.

SQLDefinition when the element is defined by two Optional values.

Usually the database constraints will enforce that both are either Some or None.

Attributes

Source
Composite.scala
def fromMultiOption[A1, A2, A3, R](a1Def: SQLDefinition[Option[A1]], a2Def: SQLDefinition[Option[A2]], a3Def: SQLDefinition[Option[A3]])(map: (A1, A2, A3) => R)(unmap: R => (A1, A2, A3)): SQLDefinition[Option[R]]

SQLDefinition when the element is defined by three Optional values.

SQLDefinition when the element is defined by three Optional values.

Usually the database constraints will enforce that both are either Some or None.

Attributes

Source
Composite.scala
def fromMultiOption[A1, A2, A3, A4, R](a1Def: SQLDefinition[Option[A1]], a2Def: SQLDefinition[Option[A2]], a3Def: SQLDefinition[Option[A3]], a4Def: SQLDefinition[Option[A4]])(map: (A1, A2, A3, A4) => R)(unmap: R => (A1, A2, A3, A4)): SQLDefinition[Option[R]]

SQLDefinition when the element is defined by four Optional values.

SQLDefinition when the element is defined by four Optional values.

Usually the database constraints will enforce that both are either Some or None.

Attributes

Source
Composite.scala
def fromMultiOption[A1, A2, A3, A4, A5, R](a1Def: SQLDefinition[Option[A1]], a2Def: SQLDefinition[Option[A2]], a3Def: SQLDefinition[Option[A3]], a4Def: SQLDefinition[Option[A4]], a5Def: SQLDefinition[Option[A5]])(map: (A1, A2, A3, A4, A5) => R)(unmap: R => (A1, A2, A3, A4, A5)): SQLDefinition[Option[R]]

SQLDefinition when the element is defined by five Optional values.

SQLDefinition when the element is defined by five Optional values.

Usually the database constraints will enforce that both are either Some or None.

Attributes

Source
Composite.scala
def fromMultiOption[A1, A2, A3, A4, A5, A6, R](a1Def: SQLDefinition[Option[A1]], a2Def: SQLDefinition[Option[A2]], a3Def: SQLDefinition[Option[A3]], a4Def: SQLDefinition[Option[A4]], a5Def: SQLDefinition[Option[A5]], a6Def: SQLDefinition[Option[A6]])(map: (A1, A2, A3, A4, A5, A6) => R)(unmap: R => (A1, A2, A3, A4, A5, A6)): SQLDefinition[Option[R]]

SQLDefinition when the element is defined by six Optional values.

SQLDefinition when the element is defined by six Optional values.

Usually the database constraints will enforce that both are either Some or None.

Attributes

Source
Composite.scala
def fromMultiOption[A1, A2, A3, A4, A5, A6, A7, R](a1Def: SQLDefinition[Option[A1]], a2Def: SQLDefinition[Option[A2]], a3Def: SQLDefinition[Option[A3]], a4Def: SQLDefinition[Option[A4]], a5Def: SQLDefinition[Option[A5]], a6Def: SQLDefinition[Option[A6]], a7Def: SQLDefinition[Option[A7]])(map: (A1, A2, A3, A4, A5, A6, A7) => R)(unmap: R => (A1, A2, A3, A4, A5, A6, A7)): SQLDefinition[Option[R]]

SQLDefinition when the element is defined by seven Optional values.

SQLDefinition when the element is defined by seven Optional values.

Usually the database constraints will enforce that both are either Some or None.

Attributes

Source
Composite.scala