Module

Database.Postgres

#Query

newtype Query a

Constructors

#Client

data Client :: Type

#Pool

data Pool :: Type

#ConnectionInfo

#ClientConfig

type ClientConfig = { database :: String, host :: String, password :: String, port :: Int, ssl :: Boolean, user :: String }

#PoolConfig

type PoolConfig = { connectionTimeoutMillis :: Int, idleTimeoutMillis :: Int, max :: Int }

#ConnectionString

#defaultPoolConfig

#connect

connect :: Pool -> Aff Client

Makes a connection to the database via a Client.

#release

#end

#execute

execute :: forall a. Query a -> Array SqlValue -> Client -> Aff Unit

Runs a query and returns nothing.

#execute_

execute_ :: forall a. Query a -> Client -> Aff Unit

Runs a query and returns nothing

#query

query :: forall a. (Foreign -> Either Error a) -> Query a -> Array SqlValue -> Client -> Aff (Array a)

Runs a query and returns all results.

#query_

query_ :: forall a. (Foreign -> Either Error a) -> Query a -> Client -> Aff (Array a)

Just like query but does not make any param replacement

#queryValue

queryValue :: forall a. (Foreign -> Either Error a) -> Query a -> Array SqlValue -> Client -> Aff (Maybe a)

Runs a query and returns a single value, if any.

#queryValue_

queryValue_ :: forall a. (Foreign -> Either Error a) -> Query a -> Client -> Aff (Maybe a)

Just like queryValue but does not make any param replacement

#queryOne

queryOne :: forall a. (Foreign -> Either Error a) -> Query a -> Array SqlValue -> Client -> Aff (Maybe a)

Runs a query and returns the first row, if any

#queryOne_

queryOne_ :: forall a. (Foreign -> Either Error a) -> Query a -> Client -> Aff (Maybe a)

Just like queryOne but does not make any param replacement

#withClient

withClient :: forall a. Pool -> (Client -> Aff a) -> Aff a

Connects to the database, calls the provided function with the client and returns the results.

Modules