database

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: May 23, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host     string
	Port     string
	Name     string
	User     string
	Password string
	SSLMode  string
}

Config holds database configuration

func NewConfig

func NewConfig(logger logging.Logger) *Config

NewConfig creates database configuration from environment variables

func (*Config) DSN

func (c *Config) DSN() string

DSN returns the database connection string

type DB

type DB struct {
	*sqlx.DB
	// contains filtered or unexported fields
}

DB wraps sqlx.DB with lifecycle management

func NewDB

func NewDB(lc fx.Lifecycle, cfg *config.Config, logger logging.Logger) (*DB, error)

NewDB creates a new database connection with proper configuration

func (*DB) PingContext

func (db *DB) PingContext(c echo.Context) error

PingContext implements the PingContexter interface for Echo

func (*DB) WithTx

func (db *DB) WithTx(ctx context.Context, fn func(*sqlx.Tx) error) error

WithTx executes a function within a transaction

Jump to

Keyboard shortcuts

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