|
|
|
|
@@ -116,6 +116,8 @@ which is implemented for:
|
|
|
|
|
- `Array a` where `a` is [`FromRow`]
|
|
|
|
|
- `Maybe a` where `a` is [`FromRow`] (equivalent to `Array.head <<< fromRows`)
|
|
|
|
|
- `a` where `a` is [`FromRow`] (throws if 0 rows yielded)
|
|
|
|
|
- `RowsAffected`
|
|
|
|
|
- Extracts the number of rows processed by the last command in the query (ex. `INSERT INTO foo (bar) VALUES ('a'), ('b')` -> `INSERT 2` -> `RowsAffected 2`)
|
|
|
|
|
|
|
|
|
|
### Data - Ranges
|
|
|
|
|
Postgres ranges are represented with [`Range`].
|
|
|
|
|
@@ -223,9 +225,11 @@ Execute [`CursorT`] monads with [`cursor`]:
|
|
|
|
|
dbMain :: PostgresT Aff Int
|
|
|
|
|
dbMain =
|
|
|
|
|
cursor @(Int /\ String) "people_cursor" "select id, name from persons" do
|
|
|
|
|
fetchOne -- Just (1 /\ "Henry")
|
|
|
|
|
fetchAll -- [2 /\ "Sarah"]
|
|
|
|
|
fetchOne -- Nothing
|
|
|
|
|
a <- fetchOne -- Just (1 /\ "Henry")
|
|
|
|
|
b <- fetchOne -- Just (2 /\ "Sarah")
|
|
|
|
|
void $ move (MoveRelative -2)
|
|
|
|
|
c <- fetchAll -- [1 /\ "Henry", 2 /\ "Sarah"]
|
|
|
|
|
d <- fetchOne -- Nothing
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Monads - `SessionT`
|
|
|
|
|
@@ -255,59 +259,59 @@ the api of [`node-postgres`]:
|
|
|
|
|
- release clients with [`Pool.release`] or [`Pool.destroy`]
|
|
|
|
|
- release with [`Pool.end`]
|
|
|
|
|
|
|
|
|
|
[`Pool`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Effect.Aff.Postgres.Pool#t:Pool
|
|
|
|
|
[`Config`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Effect.Aff.Postgres.Pool#t:Config
|
|
|
|
|
[`Pool.make`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Effect.Aff.Postgres.Pool#v:make
|
|
|
|
|
[`Pool.end`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Effect.Aff.Postgres.Pool#v:end
|
|
|
|
|
[`Pool.connect`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Effect.Aff.Postgres.Pool#v:connect
|
|
|
|
|
[`Pool.destroy`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Effect.Aff.Postgres.Pool#v:destroy
|
|
|
|
|
[`Pool.release`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Effect.Aff.Postgres.Pool#v:release
|
|
|
|
|
[`Pool`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Effect.Aff.Postgres.Pool#t:Pool
|
|
|
|
|
[`Config`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Effect.Aff.Postgres.Pool#t:Config
|
|
|
|
|
[`Pool.make`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Effect.Aff.Postgres.Pool#v:make
|
|
|
|
|
[`Pool.end`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Effect.Aff.Postgres.Pool#v:end
|
|
|
|
|
[`Pool.connect`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Effect.Aff.Postgres.Pool#v:connect
|
|
|
|
|
[`Pool.destroy`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Effect.Aff.Postgres.Pool#v:destroy
|
|
|
|
|
[`Pool.release`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Effect.Aff.Postgres.Pool#v:release
|
|
|
|
|
|
|
|
|
|
[`Client`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Effect.Aff.Postgres.Client#t:Client
|
|
|
|
|
[`Client.end`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Effect.Aff.Postgres.Client#v:end
|
|
|
|
|
[`Client.make`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Effect.Aff.Postgres.Client#v:make
|
|
|
|
|
[`Client.connected`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Effect.Aff.Postgres.Client#v:connected
|
|
|
|
|
[`Client.query`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Effect.Aff.Postgres.Client#v:query
|
|
|
|
|
[`Client.queryRaw`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Effect.Aff.Postgres.Client#v:queryRaw
|
|
|
|
|
[`Client.exec`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Effect.Aff.Postgres.Client#v:exec
|
|
|
|
|
[`Client`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Effect.Aff.Postgres.Client#t:Client
|
|
|
|
|
[`Client.end`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Effect.Aff.Postgres.Client#v:end
|
|
|
|
|
[`Client.make`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Effect.Aff.Postgres.Client#v:make
|
|
|
|
|
[`Client.connected`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Effect.Aff.Postgres.Client#v:connected
|
|
|
|
|
[`Client.query`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Effect.Aff.Postgres.Client#v:query
|
|
|
|
|
[`Client.queryRaw`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Effect.Aff.Postgres.Client#v:queryRaw
|
|
|
|
|
[`Client.exec`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Effect.Aff.Postgres.Client#v:exec
|
|
|
|
|
|
|
|
|
|
[`Range`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Data.Postgres.Range#t:Range
|
|
|
|
|
[`Range.gt`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Data.Postgres.Range#v:gt
|
|
|
|
|
[`Range.gte`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Data.Postgres.Range#v:gte
|
|
|
|
|
[`Range.lt`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Data.Postgres.Range#v:lt
|
|
|
|
|
[`Range.lte`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Data.Postgres.Range#v:lte
|
|
|
|
|
[`Range`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Data.Postgres.Range#t:Range
|
|
|
|
|
[`Range.gt`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Data.Postgres.Range#v:gt
|
|
|
|
|
[`Range.gte`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Data.Postgres.Range#v:gte
|
|
|
|
|
[`Range.lt`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Data.Postgres.Range#v:lt
|
|
|
|
|
[`Range.lte`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Data.Postgres.Range#v:lte
|
|
|
|
|
|
|
|
|
|
[`Raw`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Data.Postgres.Raw#t:Raw
|
|
|
|
|
[`Null`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Data.Postgres.Raw#t:Null
|
|
|
|
|
[`Raw`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Data.Postgres.Raw#t:Raw
|
|
|
|
|
[`Null`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Data.Postgres.Raw#t:Null
|
|
|
|
|
|
|
|
|
|
[`Serialize`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Data.Postgres#t:Serialize
|
|
|
|
|
[`Deserialize`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Data.Postgres#t:Deserialize
|
|
|
|
|
[`Rep`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Data.Postgres#t:Rep
|
|
|
|
|
[`modifyPgTypes`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Data.Postgres#v:modifyPgTypes
|
|
|
|
|
[`Serialize`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Data.Postgres#t:Serialize
|
|
|
|
|
[`Deserialize`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Data.Postgres#t:Deserialize
|
|
|
|
|
[`Rep`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Data.Postgres#t:Rep
|
|
|
|
|
[`modifyPgTypes`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Data.Postgres#v:modifyPgTypes
|
|
|
|
|
|
|
|
|
|
[`Result`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Data.Postgres.Result#t:Result
|
|
|
|
|
[`FromRow`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Data.Postgres.Result#t:FromRow
|
|
|
|
|
[`FromRows`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Data.Postgres.Result#t:FromRows
|
|
|
|
|
[`Result`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Data.Postgres.Result#t:Result
|
|
|
|
|
[`FromRow`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Data.Postgres.Result#t:FromRow
|
|
|
|
|
[`FromRows`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Data.Postgres.Result#t:FromRows
|
|
|
|
|
|
|
|
|
|
[`Query`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Data.Postgres.Query#t:Query
|
|
|
|
|
[`AsQuery`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Data.Postgres.Query#t:AsQuery
|
|
|
|
|
[`Query`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Data.Postgres.Query#t:Query
|
|
|
|
|
[`AsQuery`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Data.Postgres.Query#t:AsQuery
|
|
|
|
|
|
|
|
|
|
[`Query.Builder`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Data.Postgres.Query.Builder#t:Builder
|
|
|
|
|
[`Query.Builder.param`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Data.Postgres.Query.Builder#v:param
|
|
|
|
|
[`Query.Builder.build`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Data.Postgres.Query.Builder#v:build
|
|
|
|
|
[`Query.Builder`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Data.Postgres.Query.Builder#t:Builder
|
|
|
|
|
[`Query.Builder.param`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Data.Postgres.Query.Builder#v:param
|
|
|
|
|
[`Query.Builder.build`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Data.Postgres.Query.Builder#v:build
|
|
|
|
|
|
|
|
|
|
[`MonadCursor`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Control.Monad.Postgres#t:MonadCursor
|
|
|
|
|
[`MonadSession`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Control.Monad.Postgres#t:MonadSession
|
|
|
|
|
[`CursorT`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Control.Monad.Postgres#t:CursorT
|
|
|
|
|
[`SessionT`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Control.Monad.Postgres#t:SessionT
|
|
|
|
|
[`PostgresT`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Control.Monad.Postgres#t:PostgresT
|
|
|
|
|
[`cursor`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Control.Monad.Postgres#v:cursor
|
|
|
|
|
[`session`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Control.Monad.Postgres#v:session
|
|
|
|
|
[`transaction`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Control.Monad.Postgres#v:transaction
|
|
|
|
|
[`runPostgres`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Control.Monad.Postgres#v:runPostgres
|
|
|
|
|
[`query`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Control.Monad.Postgres#v:query
|
|
|
|
|
[`exec`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Control.Monad.Postgres#v:exec
|
|
|
|
|
[`exec_`]: https://pursuit.purescript.org//////////////////packages/purescript-postgresql/1.3.0/docs/Control.Monad.Postgres#v:exec_
|
|
|
|
|
[`MonadCursor`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Control.Monad.Postgres#t:MonadCursor
|
|
|
|
|
[`MonadSession`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Control.Monad.Postgres#t:MonadSession
|
|
|
|
|
[`CursorT`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Control.Monad.Postgres#t:CursorT
|
|
|
|
|
[`SessionT`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Control.Monad.Postgres#t:SessionT
|
|
|
|
|
[`PostgresT`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Control.Monad.Postgres#t:PostgresT
|
|
|
|
|
[`cursor`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Control.Monad.Postgres#v:cursor
|
|
|
|
|
[`session`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Control.Monad.Postgres#v:session
|
|
|
|
|
[`transaction`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Control.Monad.Postgres#v:transaction
|
|
|
|
|
[`runPostgres`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Control.Monad.Postgres#v:runPostgres
|
|
|
|
|
[`query`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Control.Monad.Postgres#v:query
|
|
|
|
|
[`exec`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Control.Monad.Postgres#v:exec
|
|
|
|
|
[`exec_`]: https://pursuit.purescript.org//////////////////////packages/purescript-postgresql/1.4.0/Control.Monad.Postgres#v:exec_
|
|
|
|
|
|
|
|
|
|
[`node-postgres`]: https://node-postgres.com/
|
|
|
|
|
[`pg-types`]: https://github.com/brianc/node-pg-types/
|
|
|
|
|
|