2026-02-19 10:21:27 +00:00
|
|
|
// Code generated by sqlc. DO NOT EDIT.
|
|
|
|
|
// versions:
|
2026-02-20 06:39:58 +00:00
|
|
|
// sqlc v1.30.0
|
2026-02-19 10:21:27 +00:00
|
|
|
// source: sites.sql
|
|
|
|
|
|
2026-02-19 11:29:44 +00:00
|
|
|
package sqlgen
|
2026-02-19 10:21:27 +00:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2026-02-26 11:23:47 +00:00
|
|
|
"database/sql"
|
2026-02-19 10:21:27 +00:00
|
|
|
)
|
|
|
|
|
|
2026-02-26 11:23:47 +00:00
|
|
|
const hasUsersAndSites = `-- name: HasUsersAndSites :one
|
|
|
|
|
SELECT (SELECT COUNT(*) FROM users) > 0 AND (SELECT COUNT(*) FROM sites) > 0 AS has_users_and_sites
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
func (q *Queries) HasUsersAndSites(ctx context.Context) (sql.NullBool, error) {
|
|
|
|
|
row := q.db.QueryRowContext(ctx, hasUsersAndSites)
|
|
|
|
|
var has_users_and_sites sql.NullBool
|
|
|
|
|
err := row.Scan(&has_users_and_sites)
|
|
|
|
|
return has_users_and_sites, err
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-19 10:21:27 +00:00
|
|
|
const insertSite = `-- name: InsertSite :one
|
|
|
|
|
INSERT INTO sites (
|
|
|
|
|
owner_id,
|
2026-02-27 22:49:43 +00:00
|
|
|
guid,
|
2026-02-19 10:21:27 +00:00
|
|
|
title,
|
2026-02-26 11:23:47 +00:00
|
|
|
tagline,
|
|
|
|
|
created_at
|
2026-02-27 22:49:43 +00:00
|
|
|
) VALUES (?, ?, ?, ?, ?)
|
2026-02-19 10:21:27 +00:00
|
|
|
RETURNING id
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
type InsertSiteParams struct {
|
2026-02-26 11:23:47 +00:00
|
|
|
OwnerID int64
|
2026-02-27 22:49:43 +00:00
|
|
|
Guid string
|
2026-02-26 11:23:47 +00:00
|
|
|
Title string
|
|
|
|
|
Tagline string
|
|
|
|
|
CreatedAt int64
|
2026-02-19 10:21:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (q *Queries) InsertSite(ctx context.Context, arg InsertSiteParams) (int64, error) {
|
2026-02-26 11:23:47 +00:00
|
|
|
row := q.db.QueryRowContext(ctx, insertSite,
|
|
|
|
|
arg.OwnerID,
|
2026-02-27 22:49:43 +00:00
|
|
|
arg.Guid,
|
2026-02-26 11:23:47 +00:00
|
|
|
arg.Title,
|
|
|
|
|
arg.Tagline,
|
|
|
|
|
arg.CreatedAt,
|
|
|
|
|
)
|
2026-02-19 10:21:27 +00:00
|
|
|
var id int64
|
|
|
|
|
err := row.Scan(&id)
|
|
|
|
|
return id, err
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-19 11:29:44 +00:00
|
|
|
const selectSiteByID = `-- name: SelectSiteByID :one
|
2026-02-27 22:49:43 +00:00
|
|
|
SELECT id, owner_id, guid, title, tagline, created_at FROM sites WHERE id = ?
|
2026-02-19 11:29:44 +00:00
|
|
|
`
|
|
|
|
|
|
|
|
|
|
func (q *Queries) SelectSiteByID(ctx context.Context, id int64) (Site, error) {
|
|
|
|
|
row := q.db.QueryRowContext(ctx, selectSiteByID, id)
|
|
|
|
|
var i Site
|
|
|
|
|
err := row.Scan(
|
|
|
|
|
&i.ID,
|
|
|
|
|
&i.OwnerID,
|
2026-02-27 22:49:43 +00:00
|
|
|
&i.Guid,
|
2026-02-19 11:29:44 +00:00
|
|
|
&i.Title,
|
|
|
|
|
&i.Tagline,
|
2026-02-26 11:23:47 +00:00
|
|
|
&i.CreatedAt,
|
2026-02-19 11:29:44 +00:00
|
|
|
)
|
|
|
|
|
return i, err
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-19 10:21:27 +00:00
|
|
|
const selectSitesOwnedByUser = `-- name: SelectSitesOwnedByUser :many
|
2026-02-27 22:49:43 +00:00
|
|
|
SELECT id, owner_id, guid, title, tagline, created_at FROM sites WHERE owner_id = ? ORDER BY title ASC
|
2026-02-19 10:21:27 +00:00
|
|
|
`
|
|
|
|
|
|
|
|
|
|
func (q *Queries) SelectSitesOwnedByUser(ctx context.Context, ownerID int64) ([]Site, error) {
|
|
|
|
|
rows, err := q.db.QueryContext(ctx, selectSitesOwnedByUser, ownerID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
defer rows.Close()
|
|
|
|
|
var items []Site
|
|
|
|
|
for rows.Next() {
|
|
|
|
|
var i Site
|
|
|
|
|
if err := rows.Scan(
|
|
|
|
|
&i.ID,
|
|
|
|
|
&i.OwnerID,
|
2026-02-27 22:49:43 +00:00
|
|
|
&i.Guid,
|
2026-02-19 10:21:27 +00:00
|
|
|
&i.Title,
|
|
|
|
|
&i.Tagline,
|
2026-02-26 11:23:47 +00:00
|
|
|
&i.CreatedAt,
|
2026-02-19 10:21:27 +00:00
|
|
|
); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
items = append(items, i)
|
|
|
|
|
}
|
|
|
|
|
if err := rows.Close(); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
return items, nil
|
|
|
|
|
}
|