Copyright | (c) Ole Krüger 2016 |
---|---|
License | BSD3 |
Maintainer | Ole Krüger <ole@vprsm.de> |
Safe Haskell | None |
Language | Haskell2010 |
- data Column = Column {}
- data ColumnType = ColumnType {}
- class Entity a => ColumnEntity a where
- data Table = Table {
- tableName :: ByteString
- tableCols :: [Column]
- class Entity a => TableEntity a where
- buildTableSchema :: Table -> QueryBuilder
- insertColumns :: Table -> QueryBuilder
- insertColumnsOn :: Table -> ByteString -> QueryBuilder
- type GenericTable a = (Generic a, GTable (AnalyzeTable a))
- describeGenericTable :: GenericTable a => proxy a -> Table
- data KColumns
- data KTable = TTable Symbol KColumns
- class GColumns rec where
- class GTable tbl where
- type family AnalyzeRecordRep org (rec :: * -> *) :: KColumns where ...
- type family AnalyzeTableRep org (dat :: * -> *) :: KTable where ...
- type AnalyzeTable a = AnalyzeTableRep a (Rep a)
Columns
Desciption of a column
Column | |
|
data ColumnType Source #
Description of a column type
ColumnType | |
|
class Entity a => ColumnEntity a where Source #
Classify a type which can be used as a column in a table.
describeColumnType :: proxy a -> ColumnType Source #
Describe the column type
Table
Description of a table
Table | |
|
class Entity a => TableEntity a where Source #
Classify a type which can be used as a table.
describeTableType :: proxy a -> Table Source #
Describe the table type.
describeTableType :: GenericTable a => proxy a -> Table Source #
Describe the table type.
buildTableSchema :: Table -> QueryBuilder Source #
Build the SQL code which describes and creates the table.
insertColumns :: Table -> QueryBuilder Source #
Insert a comma-seperated list of the fully qualified column names of a table.
insertColumnsOn :: Table -> ByteString -> QueryBuilder Source #
Similar to insertColumns
, but instead it expands the column names on an alias.
type GenericTable a = (Generic a, GTable (AnalyzeTable a)) Source #
Constraint for generic tables
describeGenericTable :: GenericTable a => proxy a -> Table Source #
Fetch the table description for a generic table type.
Helpers
Type-level description of a record
class GColumns rec where Source #
Provide the means to demote KColumns
to a value.
gDescribeColumns :: proxy rec -> [Column] Source #
Instantiate singleton
class GTable tbl where Source #
Provide the means to demote KTable
to a value.
gDescribeTable :: proxy tbl -> Table Source #
Instantiate singleton
type family AnalyzeRecordRep org (rec :: * -> *) :: KColumns where ... Source #
AnalyzeRecordRep org (S1 (MetaSel (Just name) m1 m2 m3) (Rec0 typ)) = TSelector name typ | |
AnalyzeRecordRep org (S1 (MetaSel Nothing m1 m2 m3) a) = TypeError ((Text "Given type " :<>: ShowType org) :<>: Text " must have a single record constructor") | |
AnalyzeRecordRep org (lhs :*: rhs) = TCombine (AnalyzeRecordRep org lhs) (AnalyzeRecordRep org rhs) | |
AnalyzeRecordRep org U1 = TypeError ((Text "Given type " :<>: ShowType org) :<>: Text " has one constructor, therefore that constructor must have at least one field") | |
AnalyzeRecordRep org other = TypeError (((Text "Given type " :<>: ShowType org) :<>: Text " has a constructor with an invalid selector") :$$: ShowType other) |
type family AnalyzeTableRep org (dat :: * -> *) :: KTable where ... Source #
AnalyzeTableRep org (D1 meta1 (C1 (MetaCons name f True) sel)) = TTable name (AnalyzeRecordRep org sel) | |
AnalyzeTableRep org (D1 meta other) = TypeError ((Text "Given type " :<>: ShowType org) :<>: Text " must have a single record constructor") | |
AnalyzeTableRep org other = TypeError (((Text "Given type " :<>: ShowType org) :<>: Text " is not a valid data type") :$$: ShowType other) |
type AnalyzeTable a = AnalyzeTableRep a (Rep a) Source #
Analyzes a type in order to retrieve its KTable
representation.