db

package
v0.0.0-...-d881adf Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SQLStore

type SQLStore struct {
	*Queries
	// contains filtered or unexported fields
}

Store provides all functions to SQL queries and transactions

func (*SQLStore) TransferTx

func (store *SQLStore) TransferTx(ctx context.Context, arg TransferTxParams) (TransferTxResult, error)

TransferTx performs a money transfer from one account to the other. It created a transfer record, add account entries, and, update accounts balance within a single database transaction

type Store

type Store interface {
	Querier
	TransferTx(ctx context.Context, arg TransferTxParams) (TransferTxResult, error)
}

Store provides all functions to execute queries and transactions

func NewStore

func NewStore(db *sql.DB) Store

NewStore create a new store

type TransferTxParams

type TransferTxParams struct {
	FromAccountID int64 `json:"from_account_id"`
	ToAccountID   int64 `json:"to_account_id"`
	Amount        int64 `json:"amount"`
}

TransferTxParams contains input parameters of the transfer transaction

type TransferTxResult

type TransferTxResult struct {
	Transfer    Transfer `json:"transfer"`
	FromAccount Account  `json:"from_account"`
	ToAccount   Account  `json:"to_account"`
	FromEntry   Entry    `json:"from_entry"`
	ToEntry     Entry    `json:"to_entry"`
}

TransferTxResult contains the result of the transfer transaction

Jump to

Keyboard shortcuts

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