postgres

package
v0.0.0-...-6e7fa2b Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, dsn string, opts ...Option) (*sqlx.DB, error)

New creates a new connection to the PostgreSQL database and applies the provided configuration options.

func RunMigrations

func RunMigrations(path string, dsn string) error

RunMigrations applies the database migrations from the specified path using the provided Data Source Name (DSN).

Types

type Option

type Option func(*sqlx.DB)

Option represents a functional option for configuring the database connection.

func WithConnMaxIdleTime

func WithConnMaxIdleTime(d time.Duration) Option

WithConnMaxIdleTime sets the maximum idle time for a connection in the pool.

func WithConnMaxLifetime

func WithConnMaxLifetime(d time.Duration) Option

WithConnMaxLifetime sets the maximum lifetime of a connection before it is closed.

func WithMaxIdleConns

func WithMaxIdleConns(n int) Option

WithMaxIdleConns sets the maximum number of idle connections allowed in the pool.

func WithMaxOpenConns

func WithMaxOpenConns(n int) Option

WithMaxOpenConns sets the maximum number of open connections in the pool.

Jump to

Keyboard shortcuts

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