gormx

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: Apache-2.0 Imports: 14 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Must

func Must(opts ...Option) *gorm.DB

Types

type Config

type Config struct {
	Source             string   `yaml:"source"` //如果该字段不为空,则直接适用打开该链接
	Addr               string   `yaml:"addr"`
	Password           string   `yaml:"password" kms:"encode"`
	User               string   `yaml:"user"`
	DbName             string   `yaml:"db_name"`
	Timeout            int      `yaml:"timeout"`              //单位:秒钟
	WriteTimeout       int      `yaml:"write_timeout"`        //单位:秒钟
	ReadTimeout        int      `yaml:"read_timeout"`         //单位:秒钟
	MaxOpenConnections int      `yaml:"max_open_connections"` //设置打开数据库连接的最大数量。
	MaxIdleConnections int      `yaml:"max_idle_connections"` //用于设置连接池中空闲连接的最大数量
	MaxLifetime        int      `yaml:"max_lifetime"`         //单位:秒钟 设置了连接可复用的最大时间。
	LogLevel           string   `yaml:"log_level"`
	SslMode            string   `yaml:"ssl_mode"`
	ReadConfig         []Config `yaml:"read_config"`
}

Config mysql的配置字段

func (*Config) DSN

func (c *Config) DSN() string

type Dict

type Dict map[string]interface{}

func NewDict

func NewDict() Dict

func (*Dict) Scan

func (d *Dict) Scan(v interface{}) error

func (Dict) Value

func (d Dict) Value() (driver.Value, error)

type Model

type Model struct {
	ID        int64 `json:"id" gorm:"primarykey,column:id" form:"id"`
	CreatedAt int64 `json:"created_at" gorm:"column:created_at" form:"created_at"`
	UpdatedAt int64 `json:"updated_at" gorm:"column:updated_at" form:"updated_at"`
}

type Option

type Option func(*Options)

func WithConfig

func WithConfig(conf Config) Option

func WithDebug

func WithDebug() Option

WithDebug 我们现在支持用配置项`debug`来设置在不同环境的debug效果, 同时你可以使用这个方法来强制修改db实例的debug开关

type Options

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

Jump to

Keyboard shortcuts

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