hugo-cms/gen/sqlc/dbq/bundles.sql.go

82 lines
1.6 KiB
Go
Raw Normal View History

2025-02-16 00:43:22 +00:00
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// source: bundles.sql
package dbq
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const getBundleWithID = `-- name: GetBundleWithID :one
SELECT id, site_id, name, created_at, updated_at FROM bundles WHERE id = $1
`
func (q *Queries) GetBundleWithID(ctx context.Context, id int64) (Bundle, error) {
row := q.db.QueryRow(ctx, getBundleWithID, id)
var i Bundle
err := row.Scan(
&i.ID,
&i.SiteID,
&i.Name,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const insertBundle = `-- name: InsertBundle :one
INSERT INTO bundles (
site_id,
name,
created_at,
updated_at
) VALUES ($1, $2, $3, $3) RETURNING id
`
type InsertBundleParams struct {
SiteID int64
Name string
CreatedAt pgtype.Timestamp
}
func (q *Queries) InsertBundle(ctx context.Context, arg InsertBundleParams) (int64, error) {
row := q.db.QueryRow(ctx, insertBundle, arg.SiteID, arg.Name, arg.CreatedAt)
var id int64
err := row.Scan(&id)
return id, err
}
const listBundles = `-- name: ListBundles :many
SELECT id, site_id, name, created_at, updated_at FROM bundles WHERE site_id = $1
`
func (q *Queries) ListBundles(ctx context.Context, siteID int64) ([]Bundle, error) {
rows, err := q.db.Query(ctx, listBundles, siteID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Bundle
for rows.Next() {
var i Bundle
if err := rows.Scan(
&i.ID,
&i.SiteID,
&i.Name,
&i.CreatedAt,
&i.UpdatedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}