mirror of
https://github.com/VinGarcia/ksql.git
synced 2025-09-04 19:36:56 +00:00
Updated PGX Support (markdown)
parent
afcdf45cad
commit
ba77fdefe2
@ -21,11 +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
|
[examples/pgxsupport]: https://github.com/VinGarcia/ksql/blob/master/examples/pgxsupport/main.go#L92
|
||||||
|
|
||||||
```golang
|
```golang
|
||||||
|
func checkIfUserBelongsToTeams(ctx context.Context, db ksql.Provider, userID int, teamIDs []int) {
|
||||||
// Check if user belongs to either of the input teams:
|
// Check if user belongs to either of the input teams:
|
||||||
var row struct {
|
var row struct {
|
||||||
Count pgtype.Int8 `ksql:"c"`
|
Count pgtype.Int8 `ksql:"c"`
|
||||||
}
|
}
|
||||||
err = db.QueryOne(ctx, &row,
|
err := db.QueryOne(ctx, &row,
|
||||||
`SELECT count(*) as c
|
`SELECT count(*) as c
|
||||||
FROM users AS u
|
FROM users AS u
|
||||||
JOIN team_members AS tm
|
JOIN team_members AS tm
|
||||||
@ -40,4 +41,5 @@ The example query below also [available here][examples/pgxsupport] illustrates o
|
|||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Count: %+v\n", row.Count.Int)
|
fmt.Printf("Count: %+v\n", row.Count.Int)
|
||||||
|
}
|
||||||
```
|
```
|
Loading…
x
Reference in New Issue
Block a user