Module

Control.Monad.Postgres.Session

Package
purescript-postgresql
Repository
cakekindel/purescript-postgresql

#SessionT Source

type SessionT :: (Type -> Type) -> Type -> Typetype SessionT = RE Client

#MonadSession Source

class MonadSession :: (Type -> Type) -> Constraintclass (MonadAff m) <= MonadSession m  where

A monad representing a connected session to a database

Members

  • query :: forall q r. AsQuery q => FromRows r => q -> m r

    Executes a query and unmarshals the result into r

  • exec :: forall q. AsQuery q => q -> m Int

    Executes a query and returns the number of rows affected

  • exec_ :: forall q. AsQuery q => q -> m Unit

    Executes a query and discards the result

  • streamIn :: String -> m (Writable ())

    Execute a query with a Writable stream to STDIN

    Use with COPY .. FROM like so:

    w <- streamIn "COPY foo FROM STDIN WITH (FORMAT CSV, HEADER true)"
    liftEffect $ Stream.writeString "bar\n\"my bar column\"" UTF8 w
    
  • streamOut :: String -> m (Readable ())

    Execute a query with a Readable stream from STDOUT

    Use with COPY .. TO like so:

    r <- streamIn "COPY foo TO STDIN WITH (FORMAT CSV, HEADER true)"
    liftEffect $ Stream.readString r -- "bar\n\"my bar column\""
    

Instances

#handleStream Source

handleStream :: forall e m r. MonadEffect m => MonadError e m => Effect Unit -> m (Stream r) -> m (Stream r)

#onErrorOrClose Source