db

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RawOrderBySQL

func RawOrderBySQL[ListOrders ~[]string](o ListOrders, separator string) string

RawOrderBySQL generates an SQL ORDER BY clause based on the provided list of orders.

Parameters: - o: a list of orders of type ListOrders. - separator: a string used to split the orders into sort fields and sort directions.

Return: - a string representing the generated SQL ORDER BY clause.

Types

type GORMManager

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

func NewGORMManager

func NewGORMManager(d gorm.Dialector, opts ...gorm.Option) (*GORMManager, error)

NewGORMManager creates a new GORMManager instance.

Parameters: - d: the gorm.Dialector to be used for the GORMManager. - opts: a variadic parameter of gorm.Option to be applied to the GORMManager.

Returns: - *GORMManager: the newly created GORMManager instance. - error: an error if the GORMManager creation fails.

func (*GORMManager) AddReplicaDialector

func (m *GORMManager) AddReplicaDialector(d gorm.Dialector, pc PoolConfig) (*GORMManager, error)

AddReplicaDialector adds a replica dialector to the GORMManager.

Parameters: - d: the gorm.Dialector to be added as a replica. - pc: the PoolConfig containing connection settings.

Returns: - *GORMManager: the updated GORMManager instance. - error: an error if the dialector registration fails.

func (*GORMManager) AddSourceDialector

func (m *GORMManager) AddSourceDialector(d gorm.Dialector, pc PoolConfig) (*GORMManager, error)

AddSourceDialector adds a source dialector to the GORMManager.

Parameters: - d: the gorm.Dialector to be added as a source. - pc: the PoolConfig containing connection settings.

Returns: - *GORMManager: the updated GORMManager instance. - error: an error if the dialector registration fails.

func (*GORMManager) DB added in v0.2.1

func (m *GORMManager) DB() *gorm.DB

DB returns the underlying *gorm.DB instance of the GORMManager.

Parameters: - None

Returns: - *gorm.DB: the underlying *gorm.DB instance.

func (*GORMManager) WithLogger

func (m *GORMManager) WithLogger(lgr logger.Interface) *GORMManager

WithLogger sets the logger for the GORMManager instance.

Parameters: - lgr: the logger.Interface to be set for the GORMManager.

Returns: - *GORMManager: the updated GORMManager instance with the new logger.

type PoolConfig

type PoolConfig struct {
	ConnMaxIdleTime time.Duration `default:"10m"`
	ConnMaxLifetime time.Duration `default:"60m"`
	MaxIdleConns    int           `default:"5"`
	MaxOpenConns    int           `default:"10"`
}

Jump to

Keyboard shortcuts

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