dbutil

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: LGPL-2.1 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetContextGormLogger added in v0.0.8

func GetContextGormLogger(ctx context.Context) *threadsafe.SimpleSafeSlice[string]

GetContextGormLogger takes a context as input and returns a pointer to a SimpleSafeSlice of strings

func NewDBConnection added in v0.0.6

func NewDBConnection(connector DBConnector, cfg Config) (gorm.Dialector, error)

NewDBConnection establishes a new database connection.

func WithContextGormLogger added in v0.0.8

func WithContextGormLogger(ctx context.Context, w *threadsafe.SimpleSafeSlice[string]) context.Context

WithContextGormLogger takes a context and threadsafe slice (string) as inputs and returns a new context with a value

Types

type Config added in v0.0.3

type Config struct {
	Username, Password, Host, Params, Database string
	Port                                       int
}

Config stores configurations

type DBConnector added in v0.0.6

type DBConnector interface {
	OpenConnection(cfg Config) (gorm.Dialector, error)
}

DBConnector represents an interface for establishing database connections.

type LogType added in v0.0.8

type LogType int

LogType defines log type

const (
	Parallel LogType = iota
	Stdout
	JSON
	Smart
)

custom

type MySQLDialector added in v0.0.6

type MySQLDialector struct{}

MySQLDialector is the MySQL database connection

func (*MySQLDialector) OpenConnection added in v0.0.6

func (d *MySQLDialector) OpenConnection(cfg Config) (gorm.Dialector, error)

OpenConnection opens a new MySQL connection

type PostgreSQLDialector added in v0.0.6

type PostgreSQLDialector struct{}

PostgreSQLDialector is the PostgreSQL database connection

func (*PostgreSQLDialector) OpenConnection added in v0.0.6

func (d *PostgreSQLDialector) OpenConnection(cfg Config) (gorm.Dialector, error)

OpenConnection opens a new PostgreSQL connection

Jump to

Keyboard shortcuts

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