Module

Yoga.SQL.Types

Package
purescript-yoga-sql-types
Repository
rowtype-yoga/purescript-yoga-sql-types

#SQLQuery Source

data SQLQuery :: Row Type -> Typedata SQLQuery rows

A SQL query that tracks its parameters at the type level The row type r represents { paramName :: paramType, ... }

Constructors

#sqlQueryToString Source

sqlQueryToString :: forall r. SQLQuery r -> String

#SQLParameter Source

#SQLResult Source

data SQLResult

Opaque SQL result type (database-specific)

#fromSQLValue Source

#singleResult Source

singleResult :: forall @a b. SQLFromForeign a => (a -> b) -> Array SQLResult -> Either String b

#twoResults Source

twoResults :: forall @a @b c. SQLFromForeign a => SQLFromForeign b => (a -> b -> c) -> Array SQLResult -> Either String c

#threeResults Source

threeResults :: forall @a @b @c d. SQLFromForeign a => SQLFromForeign b => SQLFromForeign c => (a -> b -> c -> d) -> Array SQLResult -> Either String d

#fourResults Source

fourResults :: forall @a @b @c @d e. SQLFromForeign a => SQLFromForeign b => SQLFromForeign c => SQLFromForeign d => (a -> b -> c -> d -> e) -> Array SQLResult -> Either String e

#fiveResults Source

fiveResults :: forall @a @b @c @d @e f. SQLFromForeign a => SQLFromForeign b => SQLFromForeign c => SQLFromForeign d => SQLFromForeign e => (a -> b -> c -> d -> e -> f) -> Array SQLResult -> Either String f

#FromResultArray Source

class FromResultArray fn a | fn -> a where

Members

Instances

#SQLBuilder Source

newtype SQLBuilder :: Row Type -> Row Type -> Typenewtype SQLBuilder r1 r2

Constructors

Instances

#ToBuilder Source

class ToBuilder :: Type -> Row Type -> Row Type -> Constraintclass ToBuilder s r1 r2 | r1 -> r2, r2 -> r1 where

Members

Instances

#combineBuilders Source

combineBuilders :: forall a b r1 r2 r3. ToBuilder a r2 r3 => ToBuilder b r1 r2 => a -> b -> SQLBuilder r1 r3

Compose two builders

#(^) Source

Operator alias for Yoga.SQL.Types.combineBuilders (left-associative / precedence 8)

#sql Source

sql :: forall r. SQLBuilder () r -> SQLQuery r

Create a SQL query from a builder

#arg Source

arg :: forall @a @sym r1 r2. IsSymbol sym => ToSQLParam a => Cons sym a r1 r2 => SQLBuilder r1 r2

Add a typed parameter to the query

#int Source

int :: forall @sym r1 r2. IsSymbol sym => Cons sym Int r1 r2 => SQLBuilder r1 r2

Add an Int parameter

#str Source

str :: forall @sym r1 r2. IsSymbol sym => Cons sym String r1 r2 => SQLBuilder r1 r2

Add a String parameter

#bool Source

bool :: forall @sym r1 r2. IsSymbol sym => Cons sym Boolean r1 r2 => SQLBuilder r1 r2

Add a Boolean parameter

#num Source

num :: forall @sym r1 r2. IsSymbol sym => Cons sym Number r1 r2 => SQLBuilder r1 r2

Add a Number parameter

#nonArg Source

nonArg :: forall r. String -> SQLBuilder r r

Add a literal SQL string (no parameter)

#argsFor Source

argsFor :: forall @params. HFoldlWithIndex TurnIntoSQLParam (Map String SQLParameter) (Record params) (Map String SQLParameter) => SQLQuery params -> Record params -> Array SQLParameter

Extract parameters from a record in the correct order

#DatabaseColumns Source

newtype DatabaseColumns row

Constructors

#TableName Source

newtype TableName

Constructors

Instances

#ColumnName Source

newtype ColumnName

Constructors

Instances

#Table Source

data Table :: Row Type -> Typedata Table columns

A table with typed columns

Constructors

#MapRecord Source

data MapRecord a b

Constructors

Instances

#mapRecordWithIndex Source

mapRecordWithIndex :: forall @a @b @rin @rout. HFoldlWithIndex (MapRecord a b) (Builder (Record ()) (Record ())) (Record rin) (Builder (Record ()) (Record rout)) => (String -> a -> b) -> Record rin -> Record rout

#table Source

table :: forall @cols. Homogeneous cols SQLColumn => TableName -> Record cols -> Table cols

Create a table schema

#columnNamesOf Source

columnNamesOf :: forall cols colsRL out. RowToList cols colsRL => HFoldlWithIndex (MapRecord SQLColumn ColumnName) (Builder (Record ()) (Record ())) (Record cols) (Builder (Record ()) (Record out)) => Table cols -> Record out

Extract column names from table schema

#CreateTableStatement Source

#createTable Source

createTable :: forall cols. Homogeneous cols SQLColumn => Table cols -> CreateTableStatement

Generate CREATE TABLE statement from schema