gormx

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Expr = gorm.Expr
	Scan = gorm.Scan
)
View Source
var (
	// ErrRecordNotFound record not found error
	ErrRecordNotFound = gorm.ErrRecordNotFound
	// ErrInvalidTransaction invalid transaction when you are trying to `Commit` or `Rollback`
	ErrInvalidTransaction = gorm.ErrInvalidTransaction
	// ErrNotImplemented not implemented
	ErrNotImplemented = gorm.ErrNotImplemented
	// ErrMissingWhereClause missing where clause
	ErrMissingWhereClause = gorm.ErrMissingWhereClause
	// ErrUnsupportedRelation unsupported relations
	ErrUnsupportedRelation = gorm.ErrUnsupportedRelation
	// ErrPrimaryKeyRequired primary keys required
	ErrPrimaryKeyRequired = gorm.ErrPrimaryKeyRequired
	// ErrModelValueRequired model value required
	ErrModelValueRequired = gorm.ErrModelValueRequired
	// ErrInvalidData unsupported data
	ErrInvalidData = gorm.ErrInvalidData
	// ErrUnsupportedDriver unsupported driver
	ErrUnsupportedDriver = gorm.ErrUnsupportedDriver
	// ErrRegistered registered
	ErrRegistered = gorm.ErrRegistered
	// ErrInvalidField invalid field
	ErrInvalidField = gorm.ErrInvalidField
	// ErrEmptySlice empty slice found
	ErrEmptySlice = gorm.ErrEmptySlice
	// ErrDryRunModeUnsupported dry run mode unsupported
	ErrDryRunModeUnsupported = gorm.ErrDryRunModeUnsupported
	// ErrInvalidDB invalid db
	ErrInvalidDB = gorm.ErrInvalidDB
	// ErrInvalidValue invalid value
	ErrInvalidValue = gorm.ErrInvalidValue
	// ErrInvalidValueOfLength invalid values do not match length
	ErrInvalidValueOfLength = gorm.ErrInvalidValueOfLength
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Driver                                   string                          `config:"driver" desc:"SQLDrivers: https://github.com/golang/go/wiki/SQLDrivers"`
	DSN                                      string                          `config:"dsn" desc:"Data Source Name"`
	MaxIdleTime                              time.Duration                   `` /* 175-byte string literal not displayed */
	MaxLifeTime                              time.Duration                   `` /* 171-byte string literal not displayed */
	MaxIdleConns                             int                             `` /* 299-byte string literal not displayed */
	MaxOpenConns                             int                             `` /* 358-byte string literal not displayed */
	SkipDefaultTransaction                   bool                            `config:"skipDefaultTransaction"`
	DryRun                                   bool                            `config:"dryRun"`
	PrepareStmt                              bool                            `config:"prepareStmt"`
	DisableNestedTransaction                 bool                            `config:"disableNestedTransaction"`
	AllowGlobalUpdate                        bool                            `config:"allowGlobalUpdate"`
	DisableAutomaticPing                     bool                            `config:"disableAutomaticPing"`
	DisableForeignKeyConstraintWhenMigrating bool                            `config:"disableForeignKeyConstraintWhenMigrating"`
	QueryFields                              bool                            `config:"queryFields"`
	CreateBatchSize                          int                             `config:"createBatchSize"`
	NamingStrategy                           schema.Namer                    `config:"-"`
	NamingStrategyTablePrefix                string                          `config:"namingStrategyTablePrefix"`
	NamingStrategySingularTable              bool                            `config:"namingStrategySingularTable"`
	NamingStrategyNoLowerCase                bool                            `config:"namingStrategyNoLowerCase"`
	NamingStrategyNameReplacer               schema.Replacer                 `config:"-"`
	NowFunc                                  func() time.Time                `config:"-"`
	ConnPool                                 gorm.ConnPool                   `config:"-"`
	ClauseBuilders                           map[string]clause.ClauseBuilder `config:"-"`
	Plugins                                  map[string]gorm.Plugin          `config:"-"`
	// contains filtered or unexported fields
}

Config 配置

func DefaultConfig

func DefaultConfig(key string) *Config

DefaultConfig 默认配置

func StdConfig

func StdConfig(key string, optionFunc ...OptionFunc) *Config

StdConfig 标准配置

func (*Config) Build

func (c *Config) Build() *Gorm

Build 构建实例

func (*Config) Path

func (c *Config) Path() string

Path 实例配置目录

type DB

type DB = gorm.DB

type Gorm

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

func (Gorm) DB

func (orm Gorm) DB() *DB

func (Gorm) Name

func (orm Gorm) Name() string

func (*Gorm) Serve

func (orm *Gorm) Serve(ctx context.Context) error

func (*Gorm) Shutdown

func (orm *Gorm) Shutdown(ctx context.Context) error

type Logger

type Logger struct{}

func (*Logger) Error

func (*Logger) Error(ctx context.Context, tmpl string, args ...interface{})

func (*Logger) Info

func (*Logger) Info(ctx context.Context, tmpl string, args ...interface{})

func (*Logger) LogMode

func (l *Logger) LogMode(gormlog.LogLevel) gormlog.Interface

func (*Logger) Trace

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

func (*Logger) Warn

func (*Logger) Warn(ctx context.Context, tmpl string, args ...interface{})

type OptionFunc

type OptionFunc func(*Config)

OptionFunc 选项信息

func WithClauseBuilders added in v1.0.2

func WithClauseBuilders(builders map[string]clause.ClauseBuilder) OptionFunc

func WithConnPool added in v1.0.2

func WithConnPool(pool gorm.ConnPool) OptionFunc

func WithDialector

func WithDialector(dial gorm.Dialector) OptionFunc

func WithNamingStrategy added in v1.0.2

func WithNamingStrategy(namer schema.Namer) OptionFunc

func WithNamingStrategyNameReplacer added in v1.0.2

func WithNamingStrategyNameReplacer(replacer schema.Replacer) OptionFunc

func WithNowFunc added in v1.0.2

func WithNowFunc(fn func() time.Time) OptionFunc

func WithPlugins added in v1.0.2

func WithPlugins(plugins map[string]gorm.Plugin) OptionFunc

type Session added in v1.0.5

type Session = gorm.Session

Jump to

Keyboard shortcuts

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