database

package module
v0.0.0-...-1bcb9d8 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2021 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

database

golang gorm 封装

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGormConfig

func GetGormConfig(o *Option) *gorm.Config

func New

func New(o *Option) *gorm.DB

func SetAdapter

func SetAdapter(name string, driver Driver)

Types

type Driver

type Driver func(o *Option) *gorm.DB

type Logger

type Logger struct {
	Open                                bool          `json:"open" yaml:"open"`
	Level                               string        `json:"level" yaml:"level"`
	SlowThreshold                       time.Duration `json:"slowThreshold" yaml:"slowThreshold"`
	IgnoreRecordNotFoundError           bool          `json:"ignoreRecordNotFoundError" yaml:"ignoreRecordNotFoundError"`
	InfoStr, WarnStr, ErrStr            string
	TraceStr, TraceErrStr, TraceWarnStr string
	// contains filtered or unexported fields
}

func (*Logger) Error

func (l *Logger) Error(ctx context.Context, s string, i ...interface{})

func (*Logger) Info

func (l *Logger) Info(ctx context.Context, s string, i ...interface{})

func (*Logger) LogMode

func (l *Logger) LogMode(level logger.LogLevel) logger.Interface

func (*Logger) Trace

func (l *Logger) Trace(ctx context.Context, begin time.Time, fc func() (sql string, rowsAffected int64), err error)

func (*Logger) Warn

func (l *Logger) Warn(ctx context.Context, s string, i ...interface{})

type LoggerWriterAdapter

type LoggerWriterAdapter interface {
	Info(args ...interface{})
	Warn(args ...interface{})
	Error(args ...interface{})
}

type Option

type Option struct {
	Driver        string        `json:"driver" yaml:"driver"`
	Host          string        `json:"host" yaml:"host"`
	Port          string        `json:"port" yaml:"port"`
	DbName        string        `json:"dbName" yaml:"dbName"`
	Username      string        `json:"username" yaml:"username"`
	Password      string        `json:"password" yaml:"password"`
	Args          string        `json:"args" yaml:"args"`
	Prefix        string        `json:"prefix" yaml:"prefix"`
	LocalTime     bool          `json:"localTime" yaml:"localTime"`
	DryRun        bool          `json:"dryRun" yaml:"dryRun"`
	AutomaticPing bool          `json:"automaticPing" yaml:"automaticPing"`
	MaxIdleConns  int           `json:"maxIdleConns" yaml:"maxIdleConns"`
	MaxOpenConns  int           `json:"maxOpenConns" yaml:"maxOpenConns"`
	MaxLifetime   time.Duration `json:"maxLifetime" yaml:"maxLifetime"`
	SingularTable bool          `json:"singularTable" yaml:"singularTable"`
	Logger        *Logger       `mapstructure:"logger" json:"logger" yaml:"logger"`
	// contains filtered or unexported fields
}

func (*Option) NewLogger

func (o *Option) NewLogger(writer LoggerWriterAdapter)

Jump to

Keyboard shortcuts

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