Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Table writeFields viewFields
- = Table String (TableFields writeFields viewFields)
- | TableWithSchema String String (TableFields writeFields viewFields)
- tableIdentifier :: Table writeColumns viewColumns -> TableIdentifier
- tableColumns :: Table writeColumns viewColumns -> TableFields writeColumns viewColumns
- tableProperties :: Table writeColumns viewColumns -> TableFields writeColumns viewColumns
- data TableProperties writeColumns viewColumns = TableProperties {
- tablePropertiesWriter :: Writer writeColumns viewColumns
- tablePropertiesView :: View viewColumns
- type TableColumns = TableProperties
- type TableFields = TableProperties
- tableColumnsWriter :: TableFields writeColumns viewColumns -> Writer writeColumns viewColumns
- tableColumnsView :: TableFields writeColumns viewColumns -> View viewColumns
- newtype View columns = View columns
- newtype Writer columns dummy = Writer (forall f. Functor f => PackMap (f PrimExpr, String) () (f columns) ())
- requiredTableField :: String -> TableFields (Column a) (Column a)
- optionalTableField :: String -> TableFields (Maybe (Column a)) (Column a)
- readOnlyTableField :: String -> TableFields () (Column a)
- required :: String -> TableFields (Column a) (Column a)
- optional :: String -> TableFields (Maybe (Column a)) (Column a)
- readOnly :: String -> TableFields () (Column a)
- class TableColumn writeType sqlType | writeType -> sqlType where
- tableColumn :: String -> TableFields writeType (Column sqlType)
- tableField :: String -> TableFields writeType (Column sqlType)
- queryTable :: Unpackspec viewColumns columns -> Table writeColumns viewColumns -> Tag -> (columns, PrimQuery)
- runColumnMaker :: Unpackspec tablecolumns columns -> Tag -> tablecolumns -> (columns, [(Symbol, PrimExpr)])
- runWriter :: Writer columns columns' -> columns -> [(PrimExpr, String)]
- runWriter' :: Writer columns columns' -> NonEmpty columns -> (NonEmpty [PrimExpr], [String])
- newtype Zip a = Zip {}
- requiredW :: String -> Writer (Column a) (Column a)
- optionalW :: String -> Writer (Maybe (Column a)) (Column a)
Documentation
data Table writeFields viewFields Source #
Define a table as follows, where "id", "color", "location",
"quantity" and "radius" are the table's fields in Postgres and
the types are given in the type signature. The id
field is an
autoincrementing field (i.e. optional for writes).
data Widget a b c d e = Widget { wid :: a
, color :: b
, location :: c
, quantity :: d
, radius :: e }
$(makeAdaptorAndInstance
"pWidget" ''Widget)
widgetTable :: Table (Widget (Maybe (Field SqlInt4)) (Field SqlText) (Field SqlText)
(Field SqlInt4) (Field SqlFloat8))
(Widget (Field SqlText) (Field SqlText) (Field SqlText)
(Field SqlInt4) (Field SqlFloat8))
widgetTable = table "widgetTable"
(pWidget Widget { wid = tableField "id"
, color = tableField "color"
, location = tableField "location"
, quantity = tableField "quantity"
, radius = tableField "radius" })
The constructors of Table are internal only and will be deprecated in version 0.7.
Table String (TableFields writeFields viewFields) | For unqualified table names. Do not use the constructor. It is internal and will be deprecated in version 0.7. |
TableWithSchema String String (TableFields writeFields viewFields) | Schema name, table name, table properties. Do not use the constructor. It is internal and will be deprecated in version 0.7. |
tableIdentifier :: Table writeColumns viewColumns -> TableIdentifier Source #
tableColumns :: Table writeColumns viewColumns -> TableFields writeColumns viewColumns Source #
tableProperties :: Table writeColumns viewColumns -> TableFields writeColumns viewColumns Source #
Use tableColumns
instead. Will be deprecated soon.
data TableProperties writeColumns viewColumns Source #
Use TableFields
instead. TableProperties
will be deprecated
in version 0.7.
TableProperties | |
|
Instances
type TableColumns = TableProperties Source #
Use TableFields
instead. TableColumns
will be deprecated in
version 0.7.
type TableFields = TableProperties Source #
The new name for TableColumns
and TableProperties
which will
replace them in version 0.7.
tableColumnsWriter :: TableFields writeColumns viewColumns -> Writer writeColumns viewColumns Source #
tableColumnsView :: TableFields writeColumns viewColumns -> View viewColumns Source #
newtype Writer columns dummy Source #
Internal only. Do not use. Writer
will be deprecated in
version 0.7.
Instances
Profunctor Writer Source # | |
Defined in Opaleye.Internal.Table | |
ProductProfunctor Writer Source # | |
Functor (Writer a) Source # | |
Applicative (Writer a) Source # | |
requiredTableField :: String -> TableFields (Column a) (Column a) Source #
requiredTableField
is for fields which are not optional. You
must provide them on writes.
optionalTableField :: String -> TableFields (Maybe (Column a)) (Column a) Source #
optionalTableField
is for fields that you can omit on writes, such as
fields which have defaults or which are SERIAL.
readOnlyTableField :: String -> TableFields () (Column a) Source #
readOnlyTableField
is for fields that you must omit on writes, such as
SERIAL fields intended to auto-increment only.
required :: String -> TableFields (Column a) (Column a) Source #
Use requiredTableField
instead. required
will be deprecated
in 0.7.
optional :: String -> TableFields (Maybe (Column a)) (Column a) Source #
Use optionalTableField
instead. optional
will be deprecated
in 0.7.
readOnly :: String -> TableFields () (Column a) Source #
Use readOnlyTableField
instead. readOnly
will be deprecated
in 0.7.
class TableColumn writeType sqlType | writeType -> sqlType where Source #
tableColumn :: String -> TableFields writeType (Column sqlType) Source #
Do not use. Use tableField
instead. Will be deprecated in
0.7.
tableField :: String -> TableFields writeType (Column sqlType) Source #
Infer either a required (requiredTableField
) or optional
(optionalTableField
) field depending on
the write type. It's generally more convenient to use this
than required
or optional
but you do have to provide a type
signature instead.
Instances
TableColumn (Maybe (Column a)) a Source # | |
Defined in Opaleye.Internal.Table tableColumn :: String -> TableFields (Maybe (Column a)) (Column a) Source # tableField :: String -> TableFields (Maybe (Column a)) (Column a) Source # | |
TableColumn (Column a) a Source # | |
Defined in Opaleye.Internal.Table tableColumn :: String -> TableFields (Column a) (Column a) Source # tableField :: String -> TableFields (Column a) (Column a) Source # |
queryTable :: Unpackspec viewColumns columns -> Table writeColumns viewColumns -> Tag -> (columns, PrimQuery) Source #
runColumnMaker :: Unpackspec tablecolumns columns -> Tag -> tablecolumns -> (columns, [(Symbol, PrimExpr)]) Source #
runWriter' :: Writer columns columns' -> NonEmpty columns -> (NonEmpty [PrimExpr], [String]) Source #