-
Notifications
You must be signed in to change notification settings - Fork 863
/
Copy pathquery-building.sql.go
57 lines (49 loc) · 1.14 KB
/
query-building.sql.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.18.0
// source: query-building.sql
package jets
import (
"context"
)
const countPilots = `-- name: CountPilots :one
SELECT COUNT(*) FROM pilots
`
func (q *Queries) CountPilots(ctx context.Context) (int64, error) {
row := q.db.QueryRowContext(ctx, countPilots)
var count int64
err := row.Scan(&count)
return count, err
}
const deletePilot = `-- name: DeletePilot :exec
DELETE FROM pilots WHERE id = $1
`
func (q *Queries) DeletePilot(ctx context.Context, id int32) error {
_, err := q.db.ExecContext(ctx, deletePilot, id)
return err
}
const listPilots = `-- name: ListPilots :many
SELECT id, name FROM pilots LIMIT 5
`
func (q *Queries) ListPilots(ctx context.Context) ([]Pilot, error) {
rows, err := q.db.QueryContext(ctx, listPilots)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Pilot
for rows.Next() {
var i Pilot
if err := rows.Scan(&i.ID, &i.Name); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}