orm

package
v0.1.1-beta.2 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DriverMySQL mysql driver
	DriverMySQL = "mysql"
	// DriverPostgres postgresSQL driver
	DriverPostgres = "postgres"
	// DriverClickhouse
	DriverClickhouse = "clickhouse"

	// DefaultDatabase default db name
	DefaultDatabase = "default"
)

Variables

This section is empty.

Functions

func NewDB

func NewDB(c *Config) (db *gorm.DB)

NewDB connect to database and create a db instance

func NewLogWriter

func NewLogWriter(log log.Logger) logger.Writer

Types

type Config

type Config struct {
	Driver          string
	Name            string
	Addr            string
	UserName        string
	Password        string
	ShowLog         bool
	MaxIdleConn     int
	MaxOpenConn     int
	Timeout         time.Duration // connect timeout
	ReadTimeout     time.Duration
	WriteTimeout    time.Duration
	ConnMaxLifeTime time.Duration
	SlowThreshold   time.Duration // 慢查询时长,默认500ms
	EnableTrace     bool
}

Config database config

type LoggerWriter

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

func (*LoggerWriter) Printf

func (l *LoggerWriter) Printf(s string, v ...interface{})

type Manager

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

Manager define a manager

func NewManager

func NewManager(conf map[string]*Config) *Manager

NewManager create a database manager

func (*Manager) GetDB

func (m *Manager) GetDB(name string) (*gorm.DB, error)

GetDB get a database

Jump to

Keyboard shortcuts

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