composite-opaleye-0.5.0.0: Opaleye SQL for Frames records

Safe HaskellNone
LanguageHaskell2010

Composite.Opaleye.Update

Description

Module which provides utilities for processing updates using Opaleye and Composite

Synopsis

Documentation

class RecordToUpdate rs ss where Source #

Typeclass which allows transformation of a record from its select form to neutral update form, which boils down to wrapping fields that have defaults with Just.

Minimal complete definition

recordToUpdate

Methods

recordToUpdate :: Record rs -> Record ss Source #

Transform a Record rs obtained from the database to a Record ss representing an updated version of the row.

Opaleye's runUpdate family of functions all take an update function of the type columnsR -> columnsW, which this function implements generically for a no-op update.

Typically this function is composed with one or more lens sets which update the fields after the transformation.

Instances

RecordToUpdate ([] *) ([] *) Source #

For an empty record, just act as id.

RecordToUpdate rs ss => RecordToUpdate ((:) * ((:->) s a) rs) ((:) * ((:->) s (Maybe a)) ss) Source #

For a field whose type at selection is s :-> a but at update is s :-> Maybe a (a field which has a default value) add in a Just and recurse.

Methods

recordToUpdate :: Record ((* ': (s :-> a)) rs) -> Record ((* ': (s :-> Maybe a)) ss) Source #

RecordToUpdate rs ss => RecordToUpdate ((:) * r rs) ((:) * r ss) Source #

For a field whose type doesn't change between selection and update, just pass the field unchanged and then recurse.

Methods

recordToUpdate :: Record ((* ': r) rs) -> Record ((* ': r) ss) Source #

recordToUpdate :: RecordToUpdate rs ss => Record rs -> Record ss Source #

Transform a Record rs obtained from the database to a Record ss representing an updated version of the row.

Opaleye's runUpdate family of functions all take an update function of the type columnsR -> columnsW, which this function implements generically for a no-op update.

Typically this function is composed with one or more lens sets which update the fields after the transformation.