// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.30.0 // source: blocks.sql package dbgen import ( "context" ) const blockUser = `-- name: BlockUser :exec INSERT OR IGNORE INTO user_blocks (blocker_id, blocked_id) VALUES (?, ?) ` type BlockUserParams struct { BlockerID int64 `json:"blockerId"` BlockedID int64 `json:"blockedId"` } func (q *Queries) BlockUser(ctx context.Context, arg BlockUserParams) error { _, err := q.db.ExecContext(ctx, blockUser, arg.BlockerID, arg.BlockedID) return err } const isBlocked = `-- name: IsBlocked :one SELECT 1 FROM user_blocks WHERE blocker_id = ? AND blocked_id = ? LIMIT 1 ` type IsBlockedParams struct { BlockerID int64 `json:"blockerId"` BlockedID int64 `json:"blockedId"` } func (q *Queries) IsBlocked(ctx context.Context, arg IsBlockedParams) (int64, error) { row := q.db.QueryRowContext(ctx, isBlocked, arg.BlockerID, arg.BlockedID) var column_1 int64 err := row.Scan(&column_1) return column_1, err } const isEitherBlocked = `-- name: IsEitherBlocked :one SELECT 1 FROM user_blocks WHERE (blocker_id = ? AND blocked_id = ?) OR (blocker_id = ? AND blocked_id = ?) LIMIT 1 ` type IsEitherBlockedParams struct { BlockerID int64 `json:"blockerId"` BlockedID int64 `json:"blockedId"` BlockerID_2 int64 `json:"blockerId2"` BlockedID_2 int64 `json:"blockedId2"` } func (q *Queries) IsEitherBlocked(ctx context.Context, arg IsEitherBlockedParams) (int64, error) { row := q.db.QueryRowContext(ctx, isEitherBlocked, arg.BlockerID, arg.BlockedID, arg.BlockerID_2, arg.BlockedID_2, ) var column_1 int64 err := row.Scan(&column_1) return column_1, err } const listBlockedUsers = `-- name: ListBlockedUsers :many SELECT blocked_id FROM user_blocks WHERE blocker_id = ? ORDER BY created_at DESC ` func (q *Queries) ListBlockedUsers(ctx context.Context, blockerID int64) ([]int64, error) { rows, err := q.db.QueryContext(ctx, listBlockedUsers, blockerID) if err != nil { return nil, err } defer rows.Close() items := []int64{} for rows.Next() { var blocked_id int64 if err := rows.Scan(&blocked_id); err != nil { return nil, err } items = append(items, blocked_id) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const listBlockersOfUser = `-- name: ListBlockersOfUser :many SELECT blocker_id FROM user_blocks WHERE blocked_id = ? ` func (q *Queries) ListBlockersOfUser(ctx context.Context, blockedID int64) ([]int64, error) { rows, err := q.db.QueryContext(ctx, listBlockersOfUser, blockedID) if err != nil { return nil, err } defer rows.Close() items := []int64{} for rows.Next() { var blocker_id int64 if err := rows.Scan(&blocker_id); err != nil { return nil, err } items = append(items, blocker_id) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const unblockUser = `-- name: UnblockUser :exec DELETE FROM user_blocks WHERE blocker_id = ? AND blocked_id = ? ` type UnblockUserParams struct { BlockerID int64 `json:"blockerId"` BlockedID int64 `json:"blockedId"` } func (q *Queries) UnblockUser(ctx context.Context, arg UnblockUserParams) error { _, err := q.db.ExecContext(ctx, unblockUser, arg.BlockerID, arg.BlockedID) return err }