postgres

package
v0.0.0-...-77c56fa Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Insert = iota + 1
	Select
	Update
	Delete
)

Variables

This section is empty.

Functions

func Disconnect

func Disconnect() error

func InitPostgresDB

func InitPostgresDB(cfg *PostgresSQLConfig) error

InitPostgresDB initializes a new instance of the Database.

Types

type Log

type Log struct {
	ID            int       `json:"id"`
	TransactionID string    `json:"transaction_id"`
	Amount        string    `json:"amount"`
	Status        string    `json:"status"`
	Time          time.Time `json:"time"`
}

func NewLog

func NewLog(id string, amount string, status string, time time.Time) *Log

type LogRepository

type LogRepository interface {
	InsertLog(log *Log) error
}

func NewLogRepository

func NewLogRepository(db *PostgresDB) LogRepository

type LogRepositoryImpl

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

func (*LogRepositoryImpl) InsertLog

func (l *LogRepositoryImpl) InsertLog(log *Log) error

type PostgresDB

type PostgresDB struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func GetDB

func GetDB() (*PostgresDB, bool)

func (*PostgresDB) GetRefillableCardByUser

func (db *PostgresDB) GetRefillableCardByUser(user *models.User) (*RefillableCardDBRow, error)

func (*PostgresDB) GetRefillableCardByUserID

func (db *PostgresDB) GetRefillableCardByUserID(userId uuid.UUID) (*RefillableCardDBRow, error)

func (*PostgresDB) InsertNewRefillableCard

func (db *PostgresDB) InsertNewRefillableCard(card *models.RefillableCard) (*RefillableCardDBRow, error)

func (*PostgresDB) InsertOrUpdateRefillableCard

func (db *PostgresDB) InsertOrUpdateRefillableCard(card *models.RefillableCard) (isUpdated bool, err error)

func (*PostgresDB) UpdateRefillableCardInfo

func (db *PostgresDB) UpdateRefillableCardInfo(card *models.RefillableCard) (
	*RefillableCardDBRow, error)

type PostgresSQLConfig

type PostgresSQLConfig struct {
	DBHost     string
	DBPort     string
	DBUsername string
	DBPassword string
	DBName     string
	DBSSLMode  string
}

func LoadConfig

func LoadConfig() (*PostgresSQLConfig, error)

type Query

type Query struct {
	Type     int
	StrQuery string
}

type RefillableCardDBRow

type RefillableCardDBRow struct {
	Id          int    `json:"id"`
	UserId      string `json:"user_id"`
	CardSynonym string `json:"card_synonym"`
	CardMask    string `json:"card_mask"`
}

func (*RefillableCardDBRow) RefillableCardDBRowToCardRecord

func (c *RefillableCardDBRow) RefillableCardDBRowToCardRecord() (*models.RefillableCard, error)

Jump to

Keyboard shortcuts

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