Updated PGX Support (markdown)

Vinícius Garcia 2023-07-02 22:14:30 -03:00
parent 035d8b5b80
commit afcdf45cad

@ -21,10 +21,12 @@ The example query below also [available here][examples/pgxsupport] illustrates o
[examples/pgxsupport]: https://github.com/VinGarcia/ksql/blob/master/examples/pgxsupport/main.go#L92
```golang
// Find user iff user belongs to either team on the input list:
var user User
err = db.QueryOne(ctx, &user,
`SELECT u.*
// Check if user belongs to either of the input teams:
var row struct {
Count pgtype.Int8 `ksql:"c"`
}
err = db.QueryOne(ctx, &row,
`SELECT count(*) as c
FROM users AS u
JOIN team_members AS tm
ON u.id = tm.user_id
@ -33,12 +35,9 @@ The example query below also [available here][examples/pgxsupport] illustrates o
userID,
[]int{1, 2, 42}, // Int slices are supported by PGX
)
if err == ksql.ErrRecordNotFound {
fmt.Println("Input user does not exist or does not belong to any of the provided teams")
return
} else if err != nil {
if err != nil {
log.Fatalf("unexpected error: %s", err)
}
fmt.Printf("Found user: %+v\n", user)
fmt.Printf("Count: %+v\n", row.Count.Int)
```