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

104 lines
1.8 KiB
Go
Raw Normal View History

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// source: sites.sql
package dbq
import (
"context"
)
2025-01-26 23:19:31 +00:00
const getSiteWithID = `-- name: GetSiteWithID :one
2025-01-31 23:56:59 +00:00
SELECT id, owner_user_id, name, title, theme, props FROM sites WHERE id = $1 LIMIT 1
2025-01-26 23:19:31 +00:00
`
func (q *Queries) GetSiteWithID(ctx context.Context, id int64) (Site, error) {
row := q.db.QueryRow(ctx, getSiteWithID, id)
var i Site
err := row.Scan(
&i.ID,
2025-01-31 22:42:32 +00:00
&i.OwnerUserID,
2025-01-26 23:19:31 +00:00
&i.Name,
&i.Title,
&i.Theme,
&i.Props,
)
return i, err
}
const listSites = `-- name: ListSites :one
2025-01-31 23:56:59 +00:00
SELECT id, owner_user_id, name, title, theme, props FROM sites
`
func (q *Queries) ListSites(ctx context.Context) (Site, error) {
row := q.db.QueryRow(ctx, listSites)
var i Site
err := row.Scan(
&i.ID,
2025-01-31 22:42:32 +00:00
&i.OwnerUserID,
&i.Name,
2025-01-26 23:19:31 +00:00
&i.Title,
&i.Theme,
&i.Props,
)
return i, err
}
const newSite = `-- name: NewSite :one
2025-01-31 22:42:32 +00:00
INSERT INTO sites (
name,
2025-01-31 22:42:32 +00:00
owner_user_id,
2025-01-26 23:19:31 +00:00
title,
theme,
props
2025-01-31 23:56:59 +00:00
) VALUES ($1, $2, $3, $4, $5)
RETURNING id
`
type NewSiteParams struct {
2025-01-31 22:42:32 +00:00
Name string
OwnerUserID int64
Title string
Theme string
Props []byte
}
func (q *Queries) NewSite(ctx context.Context, arg NewSiteParams) (int64, error) {
row := q.db.QueryRow(ctx, newSite,
arg.Name,
2025-01-31 22:42:32 +00:00
arg.OwnerUserID,
2025-01-26 23:19:31 +00:00
arg.Title,
arg.Theme,
arg.Props,
)
var id int64
err := row.Scan(&id)
return id, err
}
2025-02-01 22:54:30 +00:00
const updateSite = `-- name: UpdateSite :exec
UPDATE sites SET
name = $2,
title = $3,
theme = $4
WHERE id = $1
`
type UpdateSiteParams struct {
ID int64
Name string
Title string
Theme string
}
func (q *Queries) UpdateSite(ctx context.Context, arg UpdateSiteParams) error {
_, err := q.db.Exec(ctx, updateSite,
arg.ID,
arg.Name,
arg.Title,
arg.Theme,
)
return err
}