This commit is contained in:
2026-09-05 19:57:41 +02:00
parent 090cc0f00d
commit b436e46e2a
9 changed files with 205 additions and 4 deletions
+45
View File
@@ -0,0 +1,45 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
// source: keys.sql
package db
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const getKeyByHash = `-- name: GetKeyByHash :one
SELECT k.id, k.owner_id, k.scopes, k.quota_tier, k.status, k.expires_at,
o.status AS owner_status
FROM api.keys k
JOIN api.owners o ON o.id = k.owner_id
WHERE k.key_hash = $1 AND k.status = 'active'
`
type GetKeyByHashRow struct {
ID int64
OwnerID int64
Scopes []string
QuotaTier string
Status string
ExpiresAt pgtype.Timestamptz
OwnerStatus string
}
func (q *Queries) GetKeyByHash(ctx context.Context, keyHash []byte) (GetKeyByHashRow, error) {
row := q.db.QueryRow(ctx, getKeyByHash, keyHash)
var i GetKeyByHashRow
err := row.Scan(
&i.ID,
&i.OwnerID,
&i.Scopes,
&i.QuotaTier,
&i.Status,
&i.ExpiresAt,
&i.OwnerStatus,
)
return i, err
}