db

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	Ping() error
	RetryPing(interval time.Duration, reps int) error
	Close() error
}

DB is an interface for database servers.

type MySQL

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

MySQL communicates with MySQL server.

func NewMySQL

func NewMySQL(dsn string) (*MySQL, error)

NewMySQL returns new MySQL.

func (*MySQL) Close

func (mysql *MySQL) Close() error

Close closes the db connection.

func (*MySQL) FindLedger

func (mysql *MySQL) FindLedger(ledgerID uint) (*model.Ledger, bool, error)

FindLedger retrieves ledger data with given ledgerID.

func (*MySQL) FindLedgers

func (mysql *MySQL) FindLedgers(userID string) ([]*model.Ledger, error)

FindLedgers retrieves ledger data with given userID.

func (*MySQL) FindUserLogIn

func (mysql *MySQL) FindUserLogIn(userID string) (*model.UserLogIn, bool, error)

FindUserLogIn retrieves user login data from user_login with given userID.

func (*MySQL) InsertLedger

func (mysql *MySQL) InsertLedger(userID, desc, date string, income int) (int, error)

InsertLedger inserts ledger data and returns ledger_id.

func (*MySQL) InsertUserAccount

func (mysql *MySQL) InsertUserAccount(email string) error

InsertUserAccount inserts user account data to db.

func (*MySQL) InsertUserLogIn

func (mysql *MySQL) InsertUserLogIn(email, passwd string) error

InsertUserLogIn inserts user login data to db.

func (*MySQL) Migrate

func (mysql *MySQL) Migrate(path string) error

Migrate migrates db tables if any change is detected.

func (*MySQL) Ping

func (mysql *MySQL) Ping() error

Ping verifies the db connection.

func (*MySQL) RetryPing

func (mysql *MySQL) RetryPing(interval time.Duration, reps int) error

RetryPing retries pinging db for given repetition on given interval basis.

Jump to

Keyboard shortcuts

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