database

package
v0.0.0-...-ad07483 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2025 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CustomMigrationParam = "x-migrations-table"
	CustomMigrationValue = "schema_migrations"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PostgresQuerier

type PostgresQuerier struct {
	// contains filtered or unexported fields
}

func NewPostgresQuerier

func NewPostgresQuerier(ctx context.Context, url string) (*PostgresQuerier, error)

func (*PostgresQuerier) Close

func (q *PostgresQuerier) Close()

func (*PostgresQuerier) InsertGameResult

func (q *PostgresQuerier) InsertGameResult(ctx context.Context, txn sqlx.Tx, gameResult entity.GameResult) (int, error)

func (*PostgresQuerier) SelectUser

func (q *PostgresQuerier) SelectUser(ctx context.Context, userID int) (*entity.User, error)

func (*PostgresQuerier) TransactionIDExist

func (q *PostgresQuerier) TransactionIDExist(ctx context.Context, transactionID string) (bool, error)

func (*PostgresQuerier) UpdateUserBalance

func (q *PostgresQuerier) UpdateUserBalance(ctx context.Context, txn sqlx.Tx, userID int, balance float64) error

func (*PostgresQuerier) WithTransaction

func (q *PostgresQuerier) WithTransaction(ctx context.Context, fn func(*sqlx.Tx) error) (err error)

WithTransaction creates a new transaction and handles rollback/commit based on the error object returned by the `TxFn`

type Querier

type Querier interface {
	Close()
	WithTransaction(ctx context.Context, fn func(*sqlx.Tx) error) (err error)

	SelectUser(ctx context.Context, userID int) (*entity.User, error)
	TransactionIDExist(ctx context.Context, transactionID string) (bool, error)

	InsertGameResult(ctx context.Context, txn sqlx.Tx, gameResult entity.GameResult) (int, error)
	UpdateUserBalance(ctx context.Context, txn sqlx.Tx, userID int, balance float64) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL