Documentation
¶
Index ¶
- type Author
- type AuthorLeaderboardRow
- type DBTX
- type Org
- type Post
- type PostViewsByStatusRow
- type Queries
- func (q *Queries) AuthorLeaderboard(ctx context.Context) ([]AuthorLeaderboardRow, error)
- func (q *Queries) GetAuthor(ctx context.Context, id string) (Author, error)
- func (q *Queries) PostViewsByStatus(ctx context.Context, orgID string) ([]PostViewsByStatusRow, error)
- func (q *Queries) WithTx(tx pgx.Tx) *Queries
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Author ¶
type Author struct {
ID string
OrgID string
Email string
Name string
PasswordHash string
CreatedAt pgtype.Timestamptz
UpdatedAt pgtype.Timestamptz
}
type AuthorLeaderboardRow ¶
type Org ¶
type Org struct {
ID string
Name string
Slug string
CreatedAt pgtype.Timestamptz
UpdatedAt pgtype.Timestamptz
}
A tenant. Every other table is scoped to one.
type Post ¶
type Post struct {
ID string
OrgID string
AuthorID string
Title string
Body string
Status string
ViewCount int64
PublishedAt pgtype.Timestamptz
CreatedAt pgtype.Timestamptz
UpdatedAt pgtype.Timestamptz
DeletedAt pgtype.Timestamptz
}
A blog post.
type PostViewsByStatusRow ¶
type Queries ¶
type Queries struct {
// contains filtered or unexported fields
}
func (*Queries) AuthorLeaderboard ¶
func (q *Queries) AuthorLeaderboard(ctx context.Context) ([]AuthorLeaderboardRow, error)
These are deliberately the queries sqlb is bad at.
sqlb's non-goal is static analytical SQL: a window function or a recursive CTE goes through sqlb.Raw, which is an escape hatch rather than a feature (ADR-0009). sqlc types both at compile time, which is its whole guarantee. So they live here, and the filterable list endpoints live in sqlb. A window function: rank authors within their org by published posts. Nothing about this benefits from being expressible as a runtime filter.
func (*Queries) GetAuthor ¶
A plain lookup, included only so the generated Author struct exists for the adoption test to point sqlb.Describe at.
func (*Queries) PostViewsByStatus ¶
func (q *Queries) PostViewsByStatus(ctx context.Context, orgID string) ([]PostViewsByStatusRow, error)
A grouped aggregate over one org. sqlb can express this with Collect, but the result shape is not the table shape, so the typed guarantee is worth more here than the runtime filterability sqlb trades it for.