feat(store): generate typed queries with sqlc

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-21 23:33:28 +01:00
1 parent 018b24948e
commit 0af74267b9
6 files changed
+143

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
package store
import (
"context"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgconn"
)
type DBTX interface {
Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
Query(context.Context, string, ...interface{}) (pgx.Rows, error)
QueryRow(context.Context, string, ...interface{}) pgx.Row
}
func New(db DBTX) *Queries {
return &Queries{db: db}
}
type Queries struct {
db DBTX
}
func (q *Queries) WithTx(tx pgx.Tx) *Queries {
return &Queries{
db: tx,
}
}
+19
View File
@@ -0,0 +1,19 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
package store
import (
"time"
"github.com/google/uuid"
)
type Org struct {
ID uuid.UUID
Slug string
Name string
CreatedAt time.Time
UpdatedAt time.Time
}
+50
View File
@@ -0,0 +1,50 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
// source: orgs.sql
package store
import (
"context"
)
const createOrg = `-- name: CreateOrg :one
INSERT INTO orgs (slug, name) VALUES ($1, $2)
RETURNING id, slug, name, created_at, updated_at
`
type CreateOrgParams struct {
Slug string
Name string
}
func (q *Queries) CreateOrg(ctx context.Context, arg CreateOrgParams) (Org, error) {
row := q.db.QueryRow(ctx, createOrg, arg.Slug, arg.Name)
var i Org
err := row.Scan(
&i.ID,
&i.Slug,
&i.Name,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const getOrgBySlug = `-- name: GetOrgBySlug :one
SELECT id, slug, name, created_at, updated_at FROM orgs WHERE slug = $1
`
func (q *Queries) GetOrgBySlug(ctx context.Context, slug string) (Org, error) {
row := q.db.QueryRow(ctx, getOrgBySlug, slug)
var i Org
err := row.Scan(
&i.ID,
&i.Slug,
&i.Name,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
+16
View File
@@ -0,0 +1,16 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
package store
import (
"context"
)
type Querier interface {
CreateOrg(ctx context.Context, arg CreateOrgParams) (Org, error)
GetOrgBySlug(ctx context.Context, slug string) (Org, error)
}
var _ Querier = (*Queries)(nil)
+6
View File
@@ -0,0 +1,6 @@
-- name: CreateOrg :one
INSERT INTO orgs (slug, name) VALUES ($1, $2)
RETURNING *;
-- name: GetOrgBySlug :one
SELECT * FROM orgs WHERE slug = $1;