-
Notifications
You must be signed in to change notification settings - Fork 1
/
program.sql.go
126 lines (116 loc) · 3.31 KB
/
program.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.17.2
// source: program.sql
package db
import (
"context"
"encoding/json"
)
const getProgram = `-- name: GetProgram :one
SELECT id, json, event_id, service_id, network_id, start_at, duration, is_free, name, description, created_at, updated_at, genre FROM ` + "`" + `program` + "`" + ` WHERE ` + "`" + `id` + "`" + ` = ?
`
func (q *Queries) GetProgram(ctx context.Context, id int64) (Program, error) {
row := q.db.QueryRowContext(ctx, getProgram, id)
var i Program
err := row.Scan(
&i.ID,
&i.Json,
&i.EventID,
&i.ServiceID,
&i.NetworkID,
&i.StartAt,
&i.Duration,
&i.IsFree,
&i.Name,
&i.Description,
&i.CreatedAt,
&i.UpdatedAt,
&i.Genre,
)
return i, err
}
const createProgram = `-- name: createProgram :exec
INSERT INTO ` + "`" + `program` + "`" + ` (
` + "`" + `id` + "`" + `,
` + "`" + `json` + "`" + `,
` + "`" + `event_id` + "`" + `,
` + "`" + `service_id` + "`" + `,
` + "`" + `network_id` + "`" + `,
` + "`" + `start_at` + "`" + `,
` + "`" + `duration` + "`" + `,
` + "`" + `is_free` + "`" + `,
` + "`" + `name` + "`" + `,
` + "`" + `description` + "`" + `,
` + "`" + `genre` + "`" + `
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
`
type createProgramParams struct {
ID int64 `json:"id"`
Json json.RawMessage `json:"json"`
EventID int32 `json:"eventID"`
ServiceID int32 `json:"serviceID"`
NetworkID int32 `json:"networkID"`
StartAt int64 `json:"startAt"`
Duration int32 `json:"duration"`
IsFree bool `json:"isFree"`
Name string `json:"name"`
Description string `json:"description"`
Genre string `json:"genre"`
}
func (q *Queries) createProgram(ctx context.Context, arg createProgramParams) error {
_, err := q.db.ExecContext(ctx, createProgram,
arg.ID,
arg.Json,
arg.EventID,
arg.ServiceID,
arg.NetworkID,
arg.StartAt,
arg.Duration,
arg.IsFree,
arg.Name,
arg.Description,
arg.Genre,
)
return err
}
const updateProgram = `-- name: updateProgram :exec
UPDATE ` + "`" + `program` + "`" + ` SET
` + "`" + `json` + "`" + ` = ?,
` + "`" + `event_id` + "`" + ` = ?,
` + "`" + `service_id` + "`" + ` = ?,
` + "`" + `network_id` + "`" + ` = ?,
` + "`" + `start_at` + "`" + ` = ?,
` + "`" + `duration` + "`" + ` = ?,
` + "`" + `is_free` + "`" + ` = ?,
` + "`" + `name` + "`" + ` = ?,
` + "`" + `description` + "`" + ` = ?
WHERE id = ?
`
type updateProgramParams struct {
Json json.RawMessage `json:"json"`
EventID int32 `json:"eventID"`
ServiceID int32 `json:"serviceID"`
NetworkID int32 `json:"networkID"`
StartAt int64 `json:"startAt"`
Duration int32 `json:"duration"`
IsFree bool `json:"isFree"`
Name string `json:"name"`
Description string `json:"description"`
ID int64 `json:"id"`
}
func (q *Queries) updateProgram(ctx context.Context, arg updateProgramParams) error {
_, err := q.db.ExecContext(ctx, updateProgram,
arg.Json,
arg.EventID,
arg.ServiceID,
arg.NetworkID,
arg.StartAt,
arg.Duration,
arg.IsFree,
arg.Name,
arg.Description,
arg.ID,
)
return err
}