Refs #67 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
83 lines
1.9 KiB
Go
83 lines
1.9 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: legal.sql
|
|
|
|
package store
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
const deleteLegalDocument = `-- name: DeleteLegalDocument :exec
|
|
DELETE FROM legal_documents WHERE org_id IS NOT DISTINCT FROM $1 AND kind = $2
|
|
`
|
|
|
|
type DeleteLegalDocumentParams struct {
|
|
OrgID *uuid.UUID
|
|
Kind string
|
|
}
|
|
|
|
func (q *Queries) DeleteLegalDocument(ctx context.Context, arg DeleteLegalDocumentParams) error {
|
|
_, err := q.db.Exec(ctx, deleteLegalDocument, arg.OrgID, arg.Kind)
|
|
return err
|
|
}
|
|
|
|
const legalDocuments = `-- name: LegalDocuments :many
|
|
SELECT org_id, kind, url, markdown, updated_at FROM legal_documents
|
|
WHERE org_id IS NULL OR org_id = $1
|
|
ORDER BY org_id NULLS LAST, kind
|
|
`
|
|
|
|
// The organization's documents and the platform's, organization first.
|
|
func (q *Queries) LegalDocuments(ctx context.Context, orgID *uuid.UUID) ([]LegalDocument, error) {
|
|
rows, err := q.db.Query(ctx, legalDocuments, orgID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []LegalDocument{}
|
|
for rows.Next() {
|
|
var i LegalDocument
|
|
if err := rows.Scan(
|
|
&i.OrgID,
|
|
&i.Kind,
|
|
&i.Url,
|
|
&i.Markdown,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const upsertLegalDocument = `-- name: UpsertLegalDocument :exec
|
|
INSERT INTO legal_documents (org_id, kind, url, markdown)
|
|
VALUES ($1, $2, $3, $4)
|
|
ON CONFLICT (org_id, kind) DO UPDATE SET url = EXCLUDED.url, markdown = EXCLUDED.markdown, updated_at = now()
|
|
`
|
|
|
|
type UpsertLegalDocumentParams struct {
|
|
OrgID *uuid.UUID
|
|
Kind string
|
|
Url string
|
|
Markdown string
|
|
}
|
|
|
|
func (q *Queries) UpsertLegalDocument(ctx context.Context, arg UpsertLegalDocumentParams) error {
|
|
_, err := q.db.Exec(ctx, upsertLegalDocument,
|
|
arg.OrgID,
|
|
arg.Kind,
|
|
arg.Url,
|
|
arg.Markdown,
|
|
)
|
|
return err
|
|
}
|