mirror of
https://github.com/J3vb/OwnCord.git
synced 2026-09-03 03:50:00 +03:00
- Add sqlc.yaml config (SQLite engine, db/queries/sqlite/, db/dbgen/ output) - Pin sqlc v1.30.0 in sqlc.version - Add Makefile with sqlc-install, sqlc-generate, sqlc-verify targets - Write 14 SQL query files covering all DB domains (users, sessions, invites, channels, messages, reactions, voice, roles, attachments, admin, dm, blocks, lockouts, profile) - Commit generated db/dbgen/ package (querier interface + typed fns) - FTS5 search queries remain hand-written in message_queries.go; transactional multi-step operations unchanged in Go
70 lines
1.7 KiB
Go
70 lines
1.7 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: lockouts.sql
|
|
|
|
package dbgen
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const cleanupExpiredLockouts = `-- name: CleanupExpiredLockouts :exec
|
|
DELETE FROM rate_lockouts WHERE expires_at <= ?
|
|
`
|
|
|
|
func (q *Queries) CleanupExpiredLockouts(ctx context.Context, expiresAt string) error {
|
|
_, err := q.db.ExecContext(ctx, cleanupExpiredLockouts, expiresAt)
|
|
return err
|
|
}
|
|
|
|
const deleteLockout = `-- name: DeleteLockout :exec
|
|
DELETE FROM rate_lockouts WHERE key = ?
|
|
`
|
|
|
|
func (q *Queries) DeleteLockout(ctx context.Context, key string) error {
|
|
_, err := q.db.ExecContext(ctx, deleteLockout, key)
|
|
return err
|
|
}
|
|
|
|
const loadActiveLockouts = `-- name: LoadActiveLockouts :many
|
|
SELECT key, expires_at FROM rate_lockouts WHERE expires_at > ?
|
|
`
|
|
|
|
func (q *Queries) LoadActiveLockouts(ctx context.Context, expiresAt string) ([]RateLockout, error) {
|
|
rows, err := q.db.QueryContext(ctx, loadActiveLockouts, expiresAt)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []RateLockout{}
|
|
for rows.Next() {
|
|
var i RateLockout
|
|
if err := rows.Scan(&i.Key, &i.ExpiresAt); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const upsertLockout = `-- name: UpsertLockout :exec
|
|
INSERT OR REPLACE INTO rate_lockouts (key, expires_at) VALUES (?, ?)
|
|
`
|
|
|
|
type UpsertLockoutParams struct {
|
|
Key string `json:"key"`
|
|
ExpiresAt string `json:"expiresAt"`
|
|
}
|
|
|
|
func (q *Queries) UpsertLockout(ctx context.Context, arg UpsertLockoutParams) error {
|
|
_, err := q.db.ExecContext(ctx, upsertLockout, arg.Key, arg.ExpiresAt)
|
|
return err
|
|
}
|