forked from mtusi2026/mtusi2026lab5
106 lines
2.1 KiB
Go
106 lines
2.1 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: attachment_variants.sql
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
const createAttachmentVariant = `-- name: CreateAttachmentVariant :exec
|
|
INSERT INTO attachment_variants (
|
|
attachment_id,
|
|
pipeline_version,
|
|
variant,
|
|
s3_key,
|
|
content_type,
|
|
size_bytes,
|
|
width,
|
|
height,
|
|
sha256
|
|
) VALUES (
|
|
$1,
|
|
$2,
|
|
$3,
|
|
$4,
|
|
$5,
|
|
$6,
|
|
$7,
|
|
$8,
|
|
$9
|
|
)
|
|
`
|
|
|
|
type CreateAttachmentVariantParams struct {
|
|
AttachmentID uuid.UUID
|
|
PipelineVersion int
|
|
Variant AttachmentVariantName
|
|
S3Key string
|
|
ContentType string
|
|
SizeBytes int
|
|
Width int
|
|
Height int
|
|
Sha256 string
|
|
}
|
|
|
|
func (q *Queries) CreateAttachmentVariant(ctx context.Context, arg CreateAttachmentVariantParams) error {
|
|
_, err := q.db.Exec(ctx, createAttachmentVariant,
|
|
arg.AttachmentID,
|
|
arg.PipelineVersion,
|
|
arg.Variant,
|
|
arg.S3Key,
|
|
arg.ContentType,
|
|
arg.SizeBytes,
|
|
arg.Width,
|
|
arg.Height,
|
|
arg.Sha256,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const listAttachmentVariants = `-- name: ListAttachmentVariants :many
|
|
SELECT attachment_id, pipeline_version, variant, s3_key, content_type, size_bytes, sha256, width, height FROM attachment_variants
|
|
WHERE attachment_id = $1::uuid
|
|
AND pipeline_version = $2::int
|
|
ORDER BY variant
|
|
`
|
|
|
|
type ListAttachmentVariantsParams struct {
|
|
AttachmentID uuid.UUID
|
|
PipelineVersion int
|
|
}
|
|
|
|
func (q *Queries) ListAttachmentVariants(ctx context.Context, arg ListAttachmentVariantsParams) ([]AttachmentVariant, error) {
|
|
rows, err := q.db.Query(ctx, listAttachmentVariants, arg.AttachmentID, arg.PipelineVersion)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []AttachmentVariant{}
|
|
for rows.Next() {
|
|
var i AttachmentVariant
|
|
if err := rows.Scan(
|
|
&i.AttachmentID,
|
|
&i.PipelineVersion,
|
|
&i.Variant,
|
|
&i.S3Key,
|
|
&i.ContentType,
|
|
&i.SizeBytes,
|
|
&i.Sha256,
|
|
&i.Width,
|
|
&i.Height,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|