Documentation ¶
Index ¶
- Variables
- func Connect(options ...Options) (trx.Manager, error)
- func LoadTx(ctx trx.Context) (*gorm.DB, error)
- func NewClient(opts ...Options) (*gorm.DB, error)
- func NewTxManager(conn *gorm.DB) trx.Manager
- func WithTx(ctx context.Context, fn func(tx *gorm.DB) error) error
- type BaseCrud
- type Config
- type DBType
- type GormTransaction
- type GormTxManager
- type ID
- type Logger
- func (l *Logger) Error(_ context.Context, s string, i ...interface{})
- func (l *Logger) Info(_ context.Context, s string, i ...interface{})
- func (l *Logger) LogMode(level logger.LogLevel) logger.Interface
- func (l *Logger) Trace(ctx context.Context, begin time.Time, ...)
- func (l *Logger) Warn(_ context.Context, s string, i ...interface{})
- type LoggerOptions
- type Model
- type Options
- func ParseMysqlConfig(v *viper.Viper) []Options
- func ParseOptions(v *viper.Viper) []Options
- func ParsePostgresSqlConfig(v *viper.Viper) []Options
- func ParseSqliteOptions(v *viper.Viper) []Options
- func WithDBType(dBType DBType) Options
- func WithDsn(dsn string) Options
- func WithShowSql(showSql bool) Options
- func WithSlowThreshold(slowThreshold time.Duration) Options
- type SoftDeletion
Constants ¶
This section is empty.
Variables ¶
View Source
var (
DB *gorm.DB
)
Functions ¶
Types ¶
type GormTransaction ¶
func (*GormTransaction) Commit ¶
func (t *GormTransaction) Commit() error
func (*GormTransaction) Rollback ¶
func (t *GormTransaction) Rollback()
func (*GormTransaction) RollbackTo ¶
func (t *GormTransaction) RollbackTo(name string)
func (*GormTransaction) SavePoint ¶
func (t *GormTransaction) SavePoint(name string)
type GormTxManager ¶
type GormTxManager struct {
// contains filtered or unexported fields
}
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func NewLogger ¶
func NewLogger(options *LoggerOptions) *Logger
type LoggerOptions ¶
type LoggerOptions struct { SlowThreshold time.Duration IgnoreRecordNotFoundError bool LogLevel plumeLogger.Level }
type Options ¶
type Options interface {
Apply(c *Config)
}
func ParseMysqlConfig ¶
func ParseOptions ¶
func ParsePostgresSqlConfig ¶
func ParseSqliteOptions ¶
func WithDBType ¶
func WithDsn ¶
WithDsn, dsn example: - for postgres: host=localhost user=postgres password=123456 dbname=gorm port=5432 sslmode=disable TimeZone=Asia/Shanghai - for mysql: root:123456@tcp(127.0.0.1:3306)/gorm?charset=utf8mb4&parseTime=True&loc=Local
func WithShowSql ¶
func WithSlowThreshold ¶
type SoftDeletion ¶
Click to show internal directories.
Click to hide internal directories.