149 lines
3.1 KiB
Go
149 lines
3.1 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.27.0
|
|
// source: query.sql
|
|
|
|
package repository
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
const countIdentifiers = `-- name: CountIdentifiers :one
|
|
SELECT COUNT(*) FROM identifiers
|
|
`
|
|
|
|
func (q *Queries) CountIdentifiers(ctx context.Context) (int64, error) {
|
|
row := q.db.QueryRow(ctx, countIdentifiers)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const createIdentifier = `-- name: CreateIdentifier :one
|
|
INSERT INTO identifiers (slug)
|
|
VALUES ($1)
|
|
RETURNING id, slug, created_at, updated_at
|
|
`
|
|
|
|
func (q *Queries) CreateIdentifier(ctx context.Context, slug string) (Identifier, error) {
|
|
row := q.db.QueryRow(ctx, createIdentifier, slug)
|
|
var i Identifier
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Slug,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const deleteIdentifier = `-- name: DeleteIdentifier :exec
|
|
DELETE FROM identifiers
|
|
WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteIdentifier(ctx context.Context, id uuid.UUID) error {
|
|
_, err := q.db.Exec(ctx, deleteIdentifier, id)
|
|
return err
|
|
}
|
|
|
|
const getIdentifierById = `-- name: GetIdentifierById :one
|
|
SELECT id, slug, created_at, updated_at
|
|
FROM identifiers
|
|
WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) GetIdentifierById(ctx context.Context, id uuid.UUID) (Identifier, error) {
|
|
row := q.db.QueryRow(ctx, getIdentifierById, id)
|
|
var i Identifier
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Slug,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getIdentifierBySlug = `-- name: GetIdentifierBySlug :one
|
|
SELECT id, slug, created_at, updated_at
|
|
FROM identifiers
|
|
WHERE slug = $1
|
|
`
|
|
|
|
func (q *Queries) GetIdentifierBySlug(ctx context.Context, slug string) (Identifier, error) {
|
|
row := q.db.QueryRow(ctx, getIdentifierBySlug, slug)
|
|
var i Identifier
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Slug,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listIdentifiers = `-- name: ListIdentifiers :many
|
|
SELECT id, slug, created_at, updated_at
|
|
FROM identifiers
|
|
ORDER BY created_at DESC
|
|
LIMIT $1 OFFSET $2
|
|
`
|
|
|
|
type ListIdentifiersParams struct {
|
|
Limit int32
|
|
Offset int32
|
|
}
|
|
|
|
func (q *Queries) ListIdentifiers(ctx context.Context, arg ListIdentifiersParams) ([]Identifier, error) {
|
|
rows, err := q.db.Query(ctx, listIdentifiers, arg.Limit, arg.Offset)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Identifier
|
|
for rows.Next() {
|
|
var i Identifier
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Slug,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const updateIdentifierSlug = `-- name: UpdateIdentifierSlug :one
|
|
UPDATE identifiers
|
|
SET slug = $2, updated_at = NOW()
|
|
WHERE id = $1
|
|
RETURNING id, slug, created_at, updated_at
|
|
`
|
|
|
|
type UpdateIdentifierSlugParams struct {
|
|
ID uuid.UUID
|
|
Slug string
|
|
}
|
|
|
|
func (q *Queries) UpdateIdentifierSlug(ctx context.Context, arg UpdateIdentifierSlugParams) (Identifier, error) {
|
|
row := q.db.QueryRow(ctx, updateIdentifierSlug, arg.ID, arg.Slug)
|
|
var i Identifier
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Slug,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|