gormPostgres

package
v0.0.0-...-dc7611c Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Module(
	"gormpostgresfx",
	fx.Provide(
		provideConfig,
		NewGorm,
		NewSQLDB,
		fx.Annotate(
			NewGormHealthChecker,
			fx.As(new(health.Health)),
			fx.ResultTags(fmt.Sprintf(`group:"%s"`, "healths")),
		),
	),
)

Module provided to fxlog https://uber-go.github.io/fx/modules.html

Functions

func NewGorm

func NewGorm(cfg *GormOptions) (*gorm.DB, error)

func NewGormHealthChecker

func NewGormHealthChecker(client *sql.DB) health.Health

func NewSQLDB

func NewSQLDB(orm *gorm.DB) (*sql.DB, error)

func Paginate

func Paginate[T any](
	ctx context.Context,
	listQuery *utils.ListQuery,
	db *gorm.DB,
) (*utils.ListResult[T], error)

Types

type GormOptions

type GormOptions struct {
	Host     string `mapstructure:"host"`
	Port     int    `mapstructure:"port"`
	User     string `mapstructure:"user"`
	DBName   string `mapstructure:"dbName"`
	SSLMode  bool   `mapstructure:"sslMode"`
	Password string `mapstructure:"password"`
}

func (*GormOptions) Dns

func (h *GormOptions) Dns() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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