Module

QueryDsl

Package
purescript-querydsl
Repository
Dretch/purescript-querydsl

A type-safe and composable SQL query builder.

#SqlType Source

class SqlType t  where

Types that can be converted to/from Constant values

Members

Instances

#FromConstantConfig Source

type FromConstantConfig = { unformatDateTime :: String -> Maybe DateTime }

Passed to fromConstant to configure how values are converted from constants.

#defaultFromConstantConfig Source

defaultFromConstantConfig :: FromConstantConfig

The default configuration does nothing.

#Table Source

data Table (cols :: Row Type)

A table definition, with a row-type parameter that captures the types of the columns in the table.

#TableName Source

newtype TableName

Instances

#Column Source

newtype Column typ (required :: Boolean)

A column within a table, with the column type and optionality represented in the type of the Column

Instances

#ColumnName Source

newtype ColumnName

Instances

#SelectQuery Source

type SelectQuery results = SelectTableBuilder (SelectEndpoint results)

A query that selects data, with the type of the columns in the result represented in the type of the SelectQuery

#SelectEndpoint Source

data SelectEndpoint (results :: Row Type)

The select columns and the where-clause/order-by/limit/etc part of a select query

Instances

#UpdateQuery Source

#InsertQuery Source

#DeleteQuery Source

data DeleteQuery

A query that deletes data from a table

Instances

#Expression Source

newtype Expression result

Instances

#UntypedExpression Source

#ToExpression Source

class ToExpression a result | a -> result where

Members

Instances

#BinaryOperator Source

type BinaryOperator a b input result = ToExpression a input => ToExpression b input => a -> b -> Expression result

#UnaryOperator Source

type UnaryOperator a input result = ToExpression a input => a -> Expression result

#ErrorMessage Source

#alwaysTrue Source

alwaysTrue :: Expression Boolean

An expression that always evaluates to true. This is useful when a filtering expression argument is required but you don't want to actually filter the result.

#TableColumns Source

class TableColumns (cols :: Row Type)  where

An instance of this type class is automatically derived by the compiler for rows where each field in the row matches name: Column typ required, representing a database table column called name, having a database type compatible with the Purescript type typ, and being required or optional on insert according to required

Members

Instances

#ApplyTableColumns Source

class ApplyTableColumns (colsRL :: RowList) (colsR :: Row Type) | colsRL -> colsR where

Members

Instances

#makeTable Source

makeTable :: forall cols. TableColumns cols => String -> Table cols

Makes a table with a given name, taking the column information from the declared type.

#from Source

from :: forall cols. Table cols -> SelectTableBuilder (Record cols)

Starts a SelectTableBuilder by specifying the initial table.

#innerJoin Source

innerJoin :: forall cols. Table cols -> (Record cols -> Expression Boolean) -> SelectTableBuilder (Record cols)

Extends a SelectTableBuilder by specifying an (inner) join table.

#leftJoin Source

leftJoin :: forall cols. Table cols -> (Record cols -> Expression Boolean) -> SelectTableBuilder (Record cols)

Extends a SelectTableBuilder by specifying a (left outer) join table.

#crossJoin Source

crossJoin :: forall cols. Table cols -> SelectTableBuilder (Record cols)

Extends a SelectTableBuilder by specifying a (cross) join table.

#select Source

select :: forall results exprs. SelectExpressions exprs results => Record exprs -> SelectEndpoint results

Creates a new SelectEndpoint with the given selected columns

#where_ Source

where_ :: forall results. SelectEndpoint results -> Expression Boolean -> SelectEndpoint results

Sets the where clause to use on the SelectEndpoint

#limit Source

limit :: forall results. SelectEndpoint results -> Int -> SelectEndpoint results

Sets the limit (maximum number of rows in the result) to use on the SelectEndpoint.

#offset Source

offset :: forall results. SelectEndpoint results -> Int -> SelectEndpoint results

Sets the offset (how many rows to skip from the result) to use on the SelectEndpoint.

#OrderingExpression Source

data OrderingExpression

An expression that determines how the results are ordered.

#asc Source

asc :: forall b a. ToExpression a b => a -> OrderingExpression

Create an OrderingExpression that says to order by the given expression in ascending order

#desc Source

desc :: forall b a. ToExpression a b => a -> OrderingExpression

Create an OrderingExpression that says to order by the given expression in descending order

#orderBy Source

orderBy :: forall results. SelectEndpoint results -> Array OrderingExpression -> SelectEndpoint results

Sets the ordering to use on the SelectEndpoint

#groupBy Source

groupBy :: forall b a results. ToExpression a b => SelectEndpoint results -> a -> SelectEndpoint results

Adds a column to the group by clause - note this function is cumulative: call it multiple times to group by more than one expression.

#having Source

having :: forall results. SelectEndpoint results -> Expression Boolean -> SelectEndpoint results

Sets the having expression to use on the SelectEndpoint.

#update Source

update :: forall exprs cols. UpdateExpressions cols exprs => Table cols -> Record exprs -> Expression Boolean -> UpdateQuery

#insertInto Source

insertInto :: forall exprs cols. InsertExpressions cols exprs => Table cols -> Record exprs -> InsertQuery

#deleteFrom Source

deleteFrom :: forall cols. Table cols -> Expression Boolean -> DeleteQuery

#InsertExpressions Source

class InsertExpressions (cols :: Row Type) (exprs :: Row Type) | cols -> exprs, exprs -> cols where

Instances of this type class are automatically derived by the compiler for pairs of row types where each field in exprs matches a column in cols

Members

Instances

#ApplyInsertExpressions Source

class ApplyInsertExpressions (colsRL :: RowList) (exprsRL :: RowList) (exprsR :: Row Type)  where

Members

Instances

#SelectExpressions Source

class SelectExpressions (exprs :: Row Type) (result :: Row Type) | exprs -> result where

Members

Instances

#ApplySelectExpressions Source

class ApplySelectExpressions (exprsRL :: RowList) (exprsR :: Row Type) (resultsRL :: RowList)  where

Members

Instances

#UpdateExpressions Source

class UpdateExpressions (cols :: Row Type) (exprs :: Row Type)  where

An instance of this type class is automatically derived by the compiler when each item in exprs matches a column of the same name and type in cols.

Members

Instances

#ApplyUpdateExpressions Source

class ApplyUpdateExpressions (colsRL :: RowList) (exprsRL :: RowList) (exprsR :: Row Type)  where

Members

Instances

#prefixOperator Source

prefixOperator :: forall result input a. String -> UnaryOperator a input result

#postfixOperator Source

postfixOperator :: forall result input a. String -> UnaryOperator a input result

#binaryOperator Source

binaryOperator :: forall result input b a. String -> BinaryOperator a b input result

#unaryAggregateFunction Source

unaryAggregateFunction :: forall result input a. String -> Boolean -> UnaryOperator a input result

#nullaryFunction Source

nullaryFunction :: forall result. String -> Expression result

#columns Source

columns :: forall cols. Table cols -> Record cols

Gets the columns associated with a table.

#Query Source

class Query t  where

Members

Instances

#expressionSql Source

#ConstantsToRecord Source

class ConstantsToRecord (r :: Row Type)  where

Members

Instances

#ApplyConstantsToRecord Source

class ApplyConstantsToRecord (r :: Row Type) (rl :: RowList) | rl -> r where

Members

Instances