Documentation
¶
Index ¶
- func Exec(ctx context.Context, db *gorm.DB, sql string, args ...any) error
- func NewTxContext(ctx context.Context, tx *gorm.DB) context.Context
- func Transaction(ctx context.Context, db *gorm.DB, fn func(tx *gorm.DB) error) error
- func TxFromContext(ctx context.Context) (*gorm.DB, bool)
- type MySQL
- type MySQLConfig
- type Option
- type PageRequest
- type PageResult
- type TxManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Transaction ¶
Types ¶
type MySQLConfig ¶
type MySQLConfig struct {
Driver string `json:"driver" yaml:"driver"`
DSN string `json:"dsn" yaml:"dsn"`
MaxOpenConns int `json:"max_open_conns" yaml:"max_open_conns"`
MaxIdleConns int `json:"max_idle_conns" yaml:"max_idle_conns"`
ConnMaxLifetime string `json:"conn_max_lifetime" yaml:"conn_max_lifetime"`
SlowThreshold string `json:"slow_threshold" yaml:"slow_threshold"`
LogLevel string `json:"log_level" yaml:"log_level"`
}
type PageRequest ¶
func NormalizePage ¶
func NormalizePage(req PageRequest) PageRequest
type PageResult ¶
type PageResult[T any] struct { Items []T `json:"items"` Total int64 `json:"total"` Page int `json:"page"` PageSize int `json:"page_size"` }
func Paginate ¶
func Paginate[T any](query *gorm.DB, req PageRequest) (PageResult[T], error)
Click to show internal directories.
Click to hide internal directories.