ContentsIndex
Framework.ORM.Types
Contents
SQL query ADT
Data model ADT
Synopsis
data Tables
= TableList [SQLTable]
| TableJoin [SQLTable]
data Query
= Query {
qFields :: [SQLField]
qTables :: Tables
qWhere :: SQLCondition
qOrder :: [SQLOrder]
qGroup :: [String]
qLimits :: Maybe (Int, Int)
}
| InsertQuery {
iTable :: String
iFields :: [String]
iValues :: [String]
}
| UpdateQuery {
uTable :: String
uFields :: [String]
uValues :: [String]
uWhere :: SQLCondition
}
| DelQuery {
dTable :: String
dWhere :: SQLCondition
}
data SQLField
= QField String
| QFn String String
type SQLTable = String
data SQLCondition
= NoCondition
| forall a b . (Parameter a, Parameter b) => a :==: b
| forall a b . (Parameter a, Parameter b) => a :/=: b
| forall a b . (Parameter a, Parameter b) => a :>: b
| forall a b . (Parameter a, Parameter b) => a :<: b
| SQLCondition :&: SQLCondition
| SQLCondition :|: SQLCondition
class Parameter a where
asString :: a -> String
asValue :: a -> Maybe SqlValue
type Selector = forall a. Parameter a => a
data SQLOrder
= Asceding String
| Desceding String
class SQLFragment s where
sqlFragment :: s -> String
sqlFPair :: SQLFragment f => String -> f -> f -> String
sqlLift :: (Parameter a, Parameter a1) => String -> a -> a1 -> String
data ColumnType
= IntegerColumn
| PrimaryKey
| ForeignKey Model String
| StringColumn
| BoolColumn
| CurrentDateColumn
data Model = Model {
mName :: String
mTable :: String
mFields :: [ModelField]
mCached :: [ModelField]
related :: [(String, [Model])]
defaultOrdering :: [SQLOrder]
perPage :: Maybe Int
showMe :: Model -> String
}
data ModelField
= String ::: ColumnType
| FilledField String ColumnType SqlValue
| ValidateBy ModelField FieldValidator
| forall w . Widget w => UsingWidget ModelField w
mfName :: ModelField -> String
mfType :: ModelField -> ColumnType
SQL query ADT
data Tables
List of tables: simple list or Join
Constructors
TableList [SQLTable]
TableJoin [SQLTable]
show/hide Instances
Eq Tables
Show Tables
data Query
ADT for SQL Query
Constructors
Query
qFields :: [SQLField]Fields to select
qTables :: Tables
qWhere :: SQLConditionConditions (WHERE part)
qOrder :: [SQLOrder]ORDER BY part
qGroup :: [String]GROUP BY part
qLimits :: Maybe (Int, Int)OFFSET ... LIMIT part
InsertQuery
iTable :: StringTable
iFields :: [String]Fields list
iValues :: [String]Values
UpdateQuery
uTable :: StringTable
uFields :: [String]Fields
uValues :: [String]Values
uWhere :: SQLConditionCondition (WHERE part)
DelQuery
dTable :: String
dWhere :: SQLCondition
data SQLField
Constructors
QField StringJust a named field
QFn String StringSome function of field, e.g. count(id)
show/hide Instances
type SQLTable = String
data SQLCondition
ADT for SQL conditions
Constructors
NoCondition
forall a b . (Parameter a, Parameter b) => a :==: b
forall a b . (Parameter a, Parameter b) => a :/=: b
forall a b . (Parameter a, Parameter b) => a :>: b
forall a b . (Parameter a, Parameter b) => a :<: b
SQLCondition :&: SQLCondition
SQLCondition :|: SQLCondition
show/hide Instances
class Parameter a where
Methods
asString :: a -> String
asValue :: a -> Maybe SqlValue
show/hide Instances
Parameter String
Parameter SqlValue
type Selector = forall a. Parameter a => a
data SQLOrder
Constructors
Asceding String
Desceding String
show/hide Instances
class SQLFragment s where
Methods
sqlFragment :: s -> String
show/hide Instances
sqlFPair :: SQLFragment f => String -> f -> f -> String
sqlLift :: (Parameter a, Parameter a1) => String -> a -> a1 -> String
Data model ADT
data ColumnType
Type of DB table column
Constructors
IntegerColumn
PrimaryKey
ForeignKey Model StringForeign key parent model> <link field in parent model
StringColumn
BoolColumn
CurrentDateColumn
show/hide Instances
data Model
DB model (table) itself
Constructors
Model
mName :: StringModel name
mTable :: StringDB table name
mFields :: [ModelField]List of model fields (DB table columns)
mCached :: [ModelField]Additional fields, which are no in DB
related :: [(String, [Model])]Assoc.list of related (children) models
defaultOrdering :: [SQLOrder]How to sort list of this models by default
perPage :: Maybe IntDefault paging
showMe :: Model -> String
show/hide Instances
data ModelField
Field for Model
Constructors
String ::: ColumnType
FilledField String ColumnType SqlValue
ValidateBy ModelField FieldValidator
forall w . Widget w => UsingWidget ModelField w
show/hide Instances
mfName :: ModelField -> String
mfType :: ModelField -> ColumnType
Produced by Haddock version 2.4.2