Slightly change readme example code
This commit is contained in:
parent
97e5d9e61c
commit
6d3b1e660a
@ -34,7 +34,7 @@ data User = User
|
|||||||
instance Opium.FromRow User where
|
instance Opium.FromRow User where
|
||||||
|
|
||||||
getUsers :: Connection -> IO (Either Opium.Error [User])
|
getUsers :: Connection -> IO (Either Opium.Error [User])
|
||||||
getUsers conn = Opium.fetch_ "SELECT * FROM user" conn
|
getUsers = Opium.fetch_ "SELECT * FROM user"
|
||||||
```
|
```
|
||||||
|
|
||||||
The `Opium.FromRow` instance is implemented generically for all product types ("records"). It looks up the field name in the query result and decodes the column value using `Opium.FromField`.
|
The `Opium.FromRow` instance is implemented generically for all product types ("records"). It looks up the field name in the query result and decodes the column value using `Opium.FromField`.
|
||||||
@ -51,7 +51,7 @@ instance Opium.FromRow ScoreByAge where
|
|||||||
getScoreByAge :: Connection -> IO ScoreByAge
|
getScoreByAge :: Connection -> IO ScoreByAge
|
||||||
getScoreByAge conn = do
|
getScoreByAge conn = do
|
||||||
let query = "SELECT regr_intercept(score, age) AS t, regr_slope(score, age) AS m FROM user"
|
let query = "SELECT regr_intercept(score, age) AS t, regr_slope(score, age) AS m FROM user"
|
||||||
Right [x] <- Opium.fetch_ query conn
|
Right (Identity x) <- Opium.fetch_ query conn
|
||||||
pure x
|
pure x
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user