Documentation
¶
Index ¶
- func FormatPostgresDSN(cfg Config) string
- func GormOpen(dialector gorm.Dialector, slowThreshold time.Duration) (db *gorm.DB, err error)
- func GormOpenPostgres(cfg Config) (db *gorm.DB, err error)
- func IsQueryError(err error) bool
- func NewGormSlog(slowThreshold time.Duration) logger.Interface
- func PaginateScope(page int, num int, by string, desc bool) func(db *gorm.DB) *gorm.DB
- type Config
- type EnvConfig
- type GormMock
- type GormSlog
- func (l *GormSlog) Error(ctx context.Context, msg string, args ...interface{})
- func (l *GormSlog) Info(ctx context.Context, msg string, args ...interface{})
- func (l *GormSlog) LogMode(lvl logger.LogLevel) logger.Interface
- func (l *GormSlog) Trace(ctx context.Context, begin time.Time, ...)
- func (l *GormSlog) Warn(ctx context.Context, msg string, args ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatPostgresDSN ¶
func IsQueryError ¶
Types ¶
type Config ¶
type Config struct {
DSN string `validate:"required_without_all=Username Password Host Port Database TimeZone SSLMode"`
Username string `validate:"required_with_all=Password Host Port Database TimeZone SSLMode,required_without=DSN"`
Password string `validate:"required_with_all=Username Host Port Database TimeZone SSLMode,required_without=DSN"`
Host string `validate:"required_with_all=Username Password Port Database TimeZone SSLMode,required_without=DSN,hostname"`
Port int `validate:"required_with_all=Username Password Host Database TimeZone SSLMode,required_without=DSN,number"`
Database string `validate:"required_with_all=Username Password Host Port TimeZone SSLMode,required_without=DSN"`
TimeZone string `validate:"required_with_all=Username Password Host Port Database SSLMode,required_without=DSN"`
SSLMode string `validate:"required_with_all=Username Password Host Port Database TimeZone,required_without=DSN"`
SlowThreshold time.Duration
}
func FromEnvConfig ¶
type EnvConfig ¶
type EnvConfig struct {
DSN string `env:"POSTGRES_DSN" validate:"required_without_all=Username Password Host Port Database TimeZone SSLMode"`
Username string `env:"POSTGRES_USERNAME" validate:"required_with_all=Password Host Port Database TimeZone SSLMode,required_without=DSN"`
Password string `env:"POSTGRES_PASSWORD" validate:"required_with_all=Username Host Port Database TimeZone SSLMode,required_without=DSN"`
Host string `` /* 137-byte string literal not displayed */
Port int `env:"POSTGRES_PORT" validate:"required_with_all=Username Password Host Database TimeZone SSLMode,required_without=DSN,number"`
Database string `env:"POSTGRES_DATABASE" validate:"required_with_all=Username Password Host Port TimeZone SSLMode,required_without=DSN"`
TimeZone string `env:"POSTGRES_TIMEZONE" validate:"required_with_all=Username Password Host Port Database SSLMode,required_without=DSN"`
SSLMode string `env:"POSTGRES_SSLMODE" validate:"required_with_all=Username Password Host Port Database TimeZone,required_without=DSN"`
}
type GormMock ¶
Click to show internal directories.
Click to hide internal directories.