bluebell/database/sites.sql.go

78 lines
1.5 KiB
Go
Raw Normal View History

2024-08-10 13:28:30 +01:00
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.25.0
// source: sites.sql
package database
import (
"context"
)
2024-08-16 16:48:50 +01:00
const deleteDomain = `-- name: DeleteDomain :exec
UPDATE sites
SET enable = false
WHERE domain = ?
`
func (q *Queries) DeleteDomain(ctx context.Context, domain string) error {
_, err := q.db.ExecContext(ctx, deleteDomain, domain)
return err
}
const enableDomain = `-- name: EnableDomain :exec
INSERT INTO sites (slug, domain, token)
VALUES (?, ?, ?)
`
type EnableDomainParams struct {
Slug string `json:"slug"`
Domain string `json:"domain"`
Token string `json:"token"`
}
func (q *Queries) EnableDomain(ctx context.Context, arg EnableDomainParams) error {
_, err := q.db.ExecContext(ctx, enableDomain, arg.Slug, arg.Domain, arg.Token)
return err
}
2024-08-10 13:28:30 +01:00
const getSiteByDomain = `-- name: GetSiteByDomain :one
2024-08-16 16:48:50 +01:00
SELECT id, slug, domain, token, enable
2024-08-10 13:28:30 +01:00
FROM sites
WHERE domain = ?
LIMIT 1
`
func (q *Queries) GetSiteByDomain(ctx context.Context, domain string) (Site, error) {
row := q.db.QueryRowContext(ctx, getSiteByDomain, domain)
var i Site
2024-08-16 16:48:50 +01:00
err := row.Scan(
&i.ID,
&i.Slug,
&i.Domain,
&i.Token,
&i.Enable,
)
return i, err
}
const getSiteBySlug = `-- name: GetSiteBySlug :one
SELECT id, slug, domain, token, enable
FROM sites
WHERE slug = ?
LIMIT 1
`
func (q *Queries) GetSiteBySlug(ctx context.Context, slug string) (Site, error) {
row := q.db.QueryRowContext(ctx, getSiteBySlug, slug)
var i Site
err := row.Scan(
&i.ID,
&i.Slug,
&i.Domain,
&i.Token,
&i.Enable,
)
2024-08-10 13:28:30 +01:00
return i, err
}