Documentation ¶
Index ¶
- Variables
- func DoUpdateColumns(columns ...string) clause.OnConflict
- func IfNotFound(tx *gorm.DB, repl ...error) error
- type Config
- type ConnectConfig
- type GDB
- type LoggerConfig
- type Scope
- type Service
- func (db *Service) AutoMigrate(ctx context.Context, tables ...interface{}) error
- func (db *Service) Search(ctx context.Context, table interface{}, result interface{}, search interface{}, ...) (total int64, err error)
- func (db *Service) Transaction(txf func(tx *Service) error) error
- func (db *Service) With(ctx context.Context) *GDB
- type TableConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var DoNothing = clause.OnConflict{DoNothing: true}
Functions ¶
func DoUpdateColumns ¶
func DoUpdateColumns(columns ...string) clause.OnConflict
Types ¶
type Config ¶
type Config struct { Connection ConnectConfig `json:"connection" toml:"connection" yaml:"connection"` //连接设置 Table TableConfig `json:"table" toml:"table" yaml:"table"` //表设置 Logger LoggerConfig `json:"log" toml:"log" yaml:"log"` //日志设置 SkipDefaultTransaction bool `json:"skip_default_transaction" toml:"skip_default_transaction" yaml:"skip_default_transaction"` //忽略默认事务 PrepareStmt bool `json:"prepare_stmt" toml:"prepare_stmt" yaml:"prepare_stmt"` //预准备Stmt }
type ConnectConfig ¶
type ConnectConfig struct { Host string `json:"host" toml:"host" yaml:"host"` //服务器 Port string `json:"port" toml:"port" yaml:"port"` //端口 User string `json:"user" toml:"user" yaml:"user"` //用户 Password string `json:"password" toml:"password" yaml:"password"` //密码 Database string `json:"database" toml:"database" yaml:"database"` //数据库 Args string `json:"args" toml:"args" yaml:"args"` //扩展参数 }
连接设置
type LoggerConfig ¶
type LoggerConfig struct { Level string `json:"level" toml:"level" yaml:"level"` //日志等级 Std bool `json:"std" toml:"std" yaml:"std"` //是否向 Os.Std 输出日志 File string `json:"file" toml:"file" yaml:"file"` //是否输出文件, 不带路径,存放在全局配置的logs目录下以.log命名 }
日志设置
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) AutoMigrate ¶
AutoMigrate AutoMigrate
type TableConfig ¶
type TableConfig struct { Prefix string `json:"prefix" toml:"prefix" yaml:"prefix"` //是否使用表前缀 Singular bool `json:"singular" toml:"singular" yaml:"singular"` //是否使用单数表名 }
表设置
Click to show internal directories.
Click to hide internal directories.