2025-01-26 20:39:19 +00:00
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
2025-01-26 20:39:19 +00:00
|
|
|
const listSites = `-- name: ListSites :one
|
2025-01-31 23:56:59 +00:00
|
|
|
SELECT id, owner_user_id, name, title, theme, props FROM sites
|
2025-01-26 20:39:19 +00:00
|
|
|
`
|
|
|
|
|
|
|
|
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,
|
2025-01-26 20:39:19 +00:00
|
|
|
&i.Name,
|
2025-01-26 23:19:31 +00:00
|
|
|
&i.Title,
|
2025-01-26 20:39:19 +00:00
|
|
|
&i.Theme,
|
|
|
|
&i.Props,
|
|
|
|
)
|
|
|
|
return i, err
|
|
|
|
}
|
|
|
|
|
|
|
|
const newSite = `-- name: NewSite :one
|
2025-01-31 22:42:32 +00:00
|
|
|
INSERT INTO sites (
|
2025-01-26 20:39:19 +00:00
|
|
|
name,
|
2025-01-31 22:42:32 +00:00
|
|
|
owner_user_id,
|
2025-01-26 23:19:31 +00:00
|
|
|
title,
|
2025-01-26 20:39:19 +00:00
|
|
|
theme,
|
|
|
|
props
|
2025-01-31 23:56:59 +00:00
|
|
|
) VALUES ($1, $2, $3, $4, $5)
|
2025-01-26 20:39:19 +00:00
|
|
|
RETURNING id
|
|
|
|
`
|
|
|
|
|
|
|
|
type NewSiteParams struct {
|
2025-01-31 22:42:32 +00:00
|
|
|
Name string
|
|
|
|
OwnerUserID int64
|
|
|
|
Title string
|
|
|
|
Theme string
|
|
|
|
Props []byte
|
2025-01-26 20:39:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
2025-01-26 20:39:19 +00:00
|
|
|
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
|
|
|
|
}
|