2025-01-27 04:45:53 +00:00
|
|
|
// Code generated by sqlc. DO NOT EDIT.
|
|
|
|
// versions:
|
|
|
|
// sqlc v1.28.0
|
|
|
|
// source: targets.sql
|
|
|
|
|
|
|
|
package dbq
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
)
|
|
|
|
|
|
|
|
const insertPublishTarget = `-- name: InsertPublishTarget :one
|
2025-01-31 22:42:32 +00:00
|
|
|
INSERT INTO publish_targets (
|
2025-01-27 04:45:53 +00:00
|
|
|
site_id,
|
|
|
|
role,
|
|
|
|
target_type,
|
|
|
|
url,
|
|
|
|
target_ref
|
|
|
|
) VALUES ($1, $2, $3, $4, $5)
|
|
|
|
RETURNING id
|
|
|
|
`
|
|
|
|
|
|
|
|
type InsertPublishTargetParams struct {
|
|
|
|
SiteID int64
|
|
|
|
Role TargetRole
|
|
|
|
TargetType TargetType
|
|
|
|
Url string
|
|
|
|
TargetRef string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (q *Queries) InsertPublishTarget(ctx context.Context, arg InsertPublishTargetParams) (int64, error) {
|
|
|
|
row := q.db.QueryRow(ctx, insertPublishTarget,
|
|
|
|
arg.SiteID,
|
|
|
|
arg.Role,
|
|
|
|
arg.TargetType,
|
|
|
|
arg.Url,
|
|
|
|
arg.TargetRef,
|
|
|
|
)
|
|
|
|
var id int64
|
|
|
|
err := row.Scan(&id)
|
|
|
|
return id, err
|
|
|
|
}
|
|
|
|
|
|
|
|
const listPublishTargetsOfRole = `-- name: ListPublishTargetsOfRole :many
|
2025-01-31 22:42:32 +00:00
|
|
|
SELECT id, site_id, role, target_type, url, target_ref FROM publish_targets WHERE site_id = $1 AND role = 'production'
|
2025-01-27 04:45:53 +00:00
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) ListPublishTargetsOfRole(ctx context.Context, siteID int64) ([]PublishTarget, error) {
|
|
|
|
rows, err := q.db.Query(ctx, listPublishTargetsOfRole, siteID)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
|
|
|
var items []PublishTarget
|
|
|
|
for rows.Next() {
|
|
|
|
var i PublishTarget
|
|
|
|
if err := rows.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.SiteID,
|
|
|
|
&i.Role,
|
|
|
|
&i.TargetType,
|
|
|
|
&i.Url,
|
|
|
|
&i.TargetRef,
|
|
|
|
); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
items = append(items, i)
|
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return items, nil
|
|
|
|
}
|