Documentation ¶
Overview ¶
Package db contains bet/account/player/signature related CRUD functionality.
Index ¶
- type Account
- type Bet
- type Player
- type Signature
- type Store
- func (s Store) AddPlayer(ctx context.Context, player Player) error
- func (s Store) AddSignature(ctx context.Context, signature Signature) error
- func (s Store) CreateAccount(ctx context.Context, account Account) error
- func (s Store) CreateBet(ctx context.Context, bet Bet) error
- func (s Store) DeleteBet(ctx context.Context, betID string) error
- func (s Store) QueryAccountByAddress(ctx context.Context, address string) (Account, error)
- func (s Store) QueryAccounts(ctx context.Context, pageNumber, rowsPerPage int) ([]Account, error)
- func (s Store) QueryBet(ctx context.Context, pageNumber int, rowsPerPage int) ([]Bet, error)
- func (s Store) QueryBetByExpiration(ctx context.Context, start, end time.Time, pageNumber int, rowsPerPage int) ([]Bet, error)
- func (s Store) QueryBetByID(ctx context.Context, betID string) (Bet, error)
- func (s Store) QueryBetByModeratorAddress(ctx context.Context, moderatorAddress string, pageNumber int, rowsPerPage int) ([]Bet, error)
- func (s Store) QueryBetByPlayerAddress(ctx context.Context, playerAddress string, pageNumber int, rowsPerPage int) ([]Bet, error)
- func (s Store) QueryBetByStatus(ctx context.Context, status string, pageNumber int, rowsPerPage int) ([]Bet, error)
- func (s Store) QueryBetPlayers(ctx context.Context, betID string, pageNumber int, rowsPerPage int) ([]Player, error)
- func (s Store) QueryBetSignatures(ctx context.Context, betID string, pageNumber int, rowsPerPage int) ([]Signature, error)
- func (s Store) Tran(tx sqlx.ExtContext) Store
- func (s Store) UpdateAccount(ctx context.Context, account Account) error
- func (s Store) UpdateBet(ctx context.Context, bet Bet) error
- func (s Store) WithinTran(ctx context.Context, fn func(sqlx.ExtContext) error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bet ¶
type Bet struct { ID string `db:"bet_id"` Status string `db:"status_id"` Description string `db:"description"` Terms string `db:"terms"` Amount int `db:"amount"` ModeratorAddress string `db:"moderator_address"` DateExpired time.Time `db:"date_expired"` DateCreated time.Time `db:"date_created"` DateUpdated time.Time `db:"date_updated"` }
Bet represents an individual bet.
type Player ¶
type Player struct { BetID string `db:"bet_id"` Address string `db:"address"` InFavor bool `db:"in_favor"` }
Player represents the connection between a Bet and an Account that is in a player role.
type Signature ¶
type Signature struct { BetID string `db:"bet_id"` Address string `db:"address"` Nonce int `db:"nonce"` Signature string `db:"signature"` DateSigned time.Time `db:"date_signed"` }
Signature represents an individual signature by an Account on a Bet.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages the set of APIs for bet access.
func NewStore ¶
func NewStore(log *zap.SugaredLogger, db *sqlx.DB) Store
NewStore constructs a data for api access.
func (Store) AddSignature ¶
AddSignature adds a new player signature to an existing bet.
func (Store) CreateAccount ¶
CreateAccount inserts a new Account into the database.
func (Store) QueryAccountByAddress ¶
QueryAccountByAddress QueryAccountsByAddress retrieves an account by address.
func (Store) QueryAccounts ¶
QueryAccounts retrieves a list of existing accounts from the database.
func (Store) QueryBetByExpiration ¶
func (s Store) QueryBetByExpiration(ctx context.Context, start, end time.Time, pageNumber int, rowsPerPage int) ([]Bet, error)
QueryBetByExpiration queries bets by expiration date by providing a start and end time.
func (Store) QueryBetByID ¶
QueryBetByID gets the specified bet from the database.
func (Store) QueryBetByModeratorAddress ¶
func (s Store) QueryBetByModeratorAddress(ctx context.Context, moderatorAddress string, pageNumber int, rowsPerPage int) ([]Bet, error)
QueryBetByModeratorAddress retrieves all bets with the specified address as a moderator for the bet.
func (Store) QueryBetByPlayerAddress ¶
func (s Store) QueryBetByPlayerAddress(ctx context.Context, playerAddress string, pageNumber int, rowsPerPage int) ([]Bet, error)
QueryBetByPlayerAddress retrieves all bets filtering by a player address.
func (Store) QueryBetByStatus ¶
func (s Store) QueryBetByStatus(ctx context.Context, status string, pageNumber int, rowsPerPage int) ([]Bet, error)
QueryBetByStatus queries bets by their status.
func (Store) QueryBetPlayers ¶
func (s Store) QueryBetPlayers(ctx context.Context, betID string, pageNumber int, rowsPerPage int) ([]Player, error)
QueryBetPlayers queries bets_players by bet ID.
func (Store) QueryBetSignatures ¶
func (s Store) QueryBetSignatures(ctx context.Context, betID string, pageNumber int, rowsPerPage int) ([]Signature, error)
QueryBetSignatures queries bets_signatures by bet ID.
func (Store) Tran ¶
func (s Store) Tran(tx sqlx.ExtContext) Store
Tran return new Store with transaction in it.
func (Store) UpdateAccount ¶
UpdateAccount updates an existing account in the database.
func (Store) WithinTran ¶
WithinTran runs passed function and do commit/rollback at the end.