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
75 lines
1.8 KiB
Go
75 lines
1.8 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: reactions.sql
|
|
|
|
package dbgen
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
)
|
|
|
|
const addReaction = `-- name: AddReaction :exec
|
|
INSERT INTO reactions (message_id, user_id, emoji) VALUES (?, ?, ?)
|
|
`
|
|
|
|
type AddReactionParams struct {
|
|
MessageID int64 `json:"messageId"`
|
|
UserID int64 `json:"userId"`
|
|
Emoji string `json:"emoji"`
|
|
}
|
|
|
|
func (q *Queries) AddReaction(ctx context.Context, arg AddReactionParams) error {
|
|
_, err := q.db.ExecContext(ctx, addReaction, arg.MessageID, arg.UserID, arg.Emoji)
|
|
return err
|
|
}
|
|
|
|
const getReactionCounts = `-- name: GetReactionCounts :many
|
|
SELECT emoji, COUNT(*) AS count
|
|
FROM reactions WHERE message_id = ?
|
|
GROUP BY emoji
|
|
`
|
|
|
|
type GetReactionCountsRow struct {
|
|
Emoji string `json:"emoji"`
|
|
Count int64 `json:"count"`
|
|
}
|
|
|
|
func (q *Queries) GetReactionCounts(ctx context.Context, messageID int64) ([]GetReactionCountsRow, error) {
|
|
rows, err := q.db.QueryContext(ctx, getReactionCounts, messageID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []GetReactionCountsRow{}
|
|
for rows.Next() {
|
|
var i GetReactionCountsRow
|
|
if err := rows.Scan(&i.Emoji, &i.Count); 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 removeReaction = `-- name: RemoveReaction :execresult
|
|
DELETE FROM reactions WHERE message_id = ? AND user_id = ? AND emoji = ?
|
|
`
|
|
|
|
type RemoveReactionParams struct {
|
|
MessageID int64 `json:"messageId"`
|
|
UserID int64 `json:"userId"`
|
|
Emoji string `json:"emoji"`
|
|
}
|
|
|
|
func (q *Queries) RemoveReaction(ctx context.Context, arg RemoveReactionParams) (sql.Result, error) {
|
|
return q.db.ExecContext(ctx, removeReaction, arg.MessageID, arg.UserID, arg.Emoji)
|
|
}
|