owpengram-server/internal/store/postgres/sqlcgen/temp_auth_key.sql.go
2026-06-04 01:37:39 +08:00

80 lines
1.9 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
// source: temp_auth_key.sql
package sqlcgen
import (
"context"
)
const getTempAuthKeyBinding = `-- name: GetTempAuthKeyBinding :one
SELECT
temp_auth_key_id,
perm_auth_key_id,
nonce,
temp_session_id,
expires_at,
encrypted_message
FROM temp_auth_key_bindings
WHERE temp_auth_key_id = $1
`
type GetTempAuthKeyBindingRow struct {
TempAuthKeyID int64
PermAuthKeyID int64
Nonce int64
TempSessionID int64
ExpiresAt int32
EncryptedMessage []byte
}
func (q *Queries) GetTempAuthKeyBinding(ctx context.Context, tempAuthKeyID int64) (GetTempAuthKeyBindingRow, error) {
row := q.db.QueryRow(ctx, getTempAuthKeyBinding, tempAuthKeyID)
var i GetTempAuthKeyBindingRow
err := row.Scan(
&i.TempAuthKeyID,
&i.PermAuthKeyID,
&i.Nonce,
&i.TempSessionID,
&i.ExpiresAt,
&i.EncryptedMessage,
)
return i, err
}
const upsertTempAuthKeyBinding = `-- name: UpsertTempAuthKeyBinding :exec
INSERT INTO temp_auth_key_bindings (
temp_auth_key_id, perm_auth_key_id, nonce, temp_session_id, expires_at, encrypted_message
)
VALUES ($1, $2, $3, $4, $5, $6)
ON CONFLICT (temp_auth_key_id) DO UPDATE SET
perm_auth_key_id = EXCLUDED.perm_auth_key_id,
nonce = EXCLUDED.nonce,
temp_session_id = EXCLUDED.temp_session_id,
expires_at = EXCLUDED.expires_at,
encrypted_message = EXCLUDED.encrypted_message,
created_at = now()
`
type UpsertTempAuthKeyBindingParams struct {
TempAuthKeyID int64
PermAuthKeyID int64
Nonce int64
TempSessionID int64
ExpiresAt int32
EncryptedMessage []byte
}
func (q *Queries) UpsertTempAuthKeyBinding(ctx context.Context, arg UpsertTempAuthKeyBindingParams) error {
_, err := q.db.Exec(ctx, upsertTempAuthKeyBinding,
arg.TempAuthKeyID,
arg.PermAuthKeyID,
arg.Nonce,
arg.TempSessionID,
arg.ExpiresAt,
arg.EncryptedMessage,
)
return err
}