Idris2Doc : Postgres.DB

Postgres.DB

(source)

Reexports

importpublic Data.Vect.Quantifiers
importpublic Postgres.Data.ResultStatus
importpublic Postgres.Result
importpublic Postgres.Query
importpublic Control.TransitionIndexed

Definitions

withConn : HasIOio=>String-> (Conn->iob) -> (ConnectionStatus->iob) ->iob
  Open a connection to a Postgres database,
perform some actions with it, and then close
the connection.

If the database connection is established successfully,
the `onOpen` function will be executed. If the
connection cannot be established, `onError` will be
executed.

You do _not_ call `pgOpen` or `pgClose` directly
when using this function.

Visibility: export
dataDBState : Type
Totality: total
Visibility: public export
Constructors:
Open : DBState
Closed : DBState

Hints:
TransitionIndexedMonadDBStateDatabase
TransitionIndexedPointedDBStateDatabase
dataOpenResult : Type
Totality: total
Visibility: public export
Constructors:
OK : OpenResult
Failed : String->OpenResult
OpenResultState : OpenResult->DBState
Visibility: public export
dataConnection : Type
Totality: total
Visibility: export
Constructor: 
MkConnection : Conn->TypeDictionary->Connection
dataDatabase : (ty : Type) ->DBState-> (ty->DBState) ->Type
Totality: total
Visibility: export
Constructors:
DBOpen : String->DatabaseOpenResultClosedOpenResultState
DBClose : Database () Open (constClosed)
Exec : (Connection->IOa) ->DatabaseaOpen (constOpen)
DIO : IOa->Databaseas1 (consts1)
GetTypes : DatabaseTypeDictionaryOpen (constOpen)
Pure : (x : a) ->Databasea (stateFnx) stateFn
Bind : Databaseas1s2Fn-> ((x : a) ->Databaseb (s2Fnx) s3Fn) ->Databasebs1s3Fn

Hints:
TransitionIndexedMonadDBStateDatabase
TransitionIndexedPointedDBStateDatabase
liftIO' : IOa->Databaseas1 (consts1)
Visibility: export
evalDatabase : HasIOio=>DatabaseaClosed (constClosed) ->ioa
Visibility: export
initDatabase : Database () Closed (constClosed)
Visibility: export
openDatabase : String->DatabaseOpenResultClosedOpenResultState
Visibility: export
closeDatabase : Database () Open (constClosed)
Visibility: export
exec : (Connection->IOa) ->DatabaseaOpen (constOpen)
Visibility: export
unsafeExec : (Conn->IOa) ->DatabaseaOpen (constOpen)
  You can execute arbitrary things against the lower-level
Conn, including closing the database connection prematurely.

Visibility: export
withDB : HasIOio=>String->DatabaseaOpen (constOpen) ->io (EitherStringa)
  Perform some operation on an open database without closing it.
A database connection will be created beforehand and then
properly disposed of afterward.

Visibility: export
debugDumpTypes : Database () Open (constOpen)
  Dump the Postgres type dictionary for debugging purposes.

Visibility: export
stringQuery : (header : Bool) ->String->Connection->IO (EitherString (StringResultsetheader))
  Query the database interpreting all columns as strings.

Visibility: export
jsonQuery : String->Connection->IO (MaybeJSON)
  Query the database expecting a JSON result is returned.

Visibility: export
expectedQuery : (expected : VectcolsType) ->String->AllCastableexpected=>Connection->IO (EitherString (rowCount : Nat**VectrowCount (HVectexpected)))
  Query the database expecting the given array of types in each
row of the result returned.

Visibility: export
tableQuery : {auto{conArg:2932} : PostgresTablet} -> (table : t) -> (cols : Vectn (ColumnIdentifier, Type)) ->HasMappingsIdrCasttablecols=>Connection->IO (EitherString (rowCount : Nat**VectrowCount (HVect (snd<$>cols))))
  Query the given table in the database mapping each row to the given Idris type.
@param table The table to query against.
@param cols A Vect of tuples where the first element is a column name to select and
the second element is an Idris type to cast the column value to.
@param conn A database connection.

Visibility: export
tableQuery' : {auto{conArg:3018} : PostgresTablet} -> (table : t) -> (cols : Vectn (String, Type)) ->HasMappingsIdrCasttable (mapFst (MkColumnId (aliasOrNametable)) <$>cols) =>Connection->IO (EitherString (rowCount : Nat**VectrowCount (HVect (snd<$> (mapFst (MkColumnId (aliasOrNametable)) <$>cols)))))
  Query the given table in the database mapping each row to the given Idris type.
@param table The table to query against.
@param cols A Vect of tuples where the first element is a column name to select and
the second element is an Idris type to cast the column value to.
@param conn A database connection.

Visibility: export
perform : String->Connection->IOResultStatus
  Perform the given command and instead of parsing the response
just report the result status. This is useful when you don't
care if/what the response looks like, just whether the command
worked

Visibility: export
tableInsert : (table : PersistedTable) -> (cols : VectnColumnIdentifier) ->HVectcolTypes->HasLooseMappingsPGCasttable (cols `zip` colTypes) =>Connection->IOResultStatus
  Insert the given values into the given table.
@param table The table to insert into.
@param cols A Vect of column names to insert into (does
not need to be every column in the table but
there is not currently protection against omitting
a column with no default value).
@param values The values to insert.
@param conn A database connection.

Visibility: export
listen : String->Connection->IOResultStatus
  Start listening for notifications on the given channel.

Visibility: export
nextNotification : Connection->IO (MaybeNotification)
  Gets the next notification _of those sitting around locally_.
Returns `Nothing` if there are no notifications.

See `libpq` documentation on `PQnotifies` for details on the
distinction between retrieving notifications from the server and
getting the next notification that has already been retrieved.

NOTE: This function _does_ consume input to make sure no notification
sent by the server but not processed by the client yet gets
missed.

Visibility: export
notificationStream : Connection->Stream (IONotification)
  Produce a potentially infinite stream of notifications.
Unlike `nextNotificaiton`, this will wait for the server
to deliver a notification.

This _is_ an infinite sequence with a blocking wait for the
next notification so it is of somewhat limited utility
compared to checking for new notifications at a natural point
in your programs existing logic loop unless your entire loop
is dictated by notification arrival anyway.

Visibility: export