Documentation
¶
Index ¶
- Constants
- type Config
- type Database
- func (db *Database) Close() error
- func (db *Database) Connect() error
- func (db *Database) ConnectWithGormConfig(gormCfg gorm.Config) error
- func (db *Database) Ctx() *gorm.DB
- func (db *Database) MigrateDatabase(tables []interface{}) error
- func (db *Database) Reconnect() error
- func (db *Database) SetDebug()
- func (db *Database) SqlDB() *sql.DB
- type KSModel
- type Logger
- func (l *Logger) Error(ctx context.Context, s string, args ...interface{})
- func (l *Logger) Info(ctx context.Context, s string, args ...interface{})
- func (l *Logger) LogMode(gormlogger.LogLevel) gormlogger.Interface
- func (l *Logger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)
- func (l *Logger) Warn(ctx context.Context, s string, args ...interface{})
- type Model
- type MySQLConfig
Constants ¶
View Source
const ( DriverMSSQL = "mssql" DriverMySQL = "mysql" DriverSQLLite = "sqlite3" DriverPostgres = "postgres" DefaultMySQLCharset = "utf8mb4" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
func NewMySqlWithConfig ¶ added in v2.0.9
func NewMySqlWithConfig(my MySQLConfig) Database
func NewWithConfig ¶
func (*Database) ConnectWithGormConfig ¶
func (*Database) MigrateDatabase ¶
type KSModel ¶ added in v2.0.9
type KSModel struct { Uid ksuid.KSUID `json:"uid" gorm:"primary_key;type:varbinary(27);index"` CreatedAt time.Time `json:"created_at" gorm:"index"` UpdatedAt time.Time `json:"updated_at"` DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"` }
KSModel is uid alternative
type Logger ¶ added in v2.0.9
type Logger struct { SlowThreshold time.Duration SourceField string SkipErrRecordNotFound bool Debug bool }
func NewGormLog ¶ added in v2.0.9
func NewGormLogWithConfig ¶ added in v2.0.9
func (*Logger) LogMode ¶ added in v2.0.9
func (l *Logger) LogMode(gormlogger.LogLevel) gormlogger.Interface
type Model ¶
type Model struct { Seq int64 `json:"seq" gorm:"primary_key;auto_increment:false;"` Uid uuid.UUID `json:"uid" gorm:"primary_key;index"` CreatedAt time.Time `json:"created_at" gorm:"index"` UpdatedAt time.Time `json:"updated_at"` DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"` }
Model struct
Click to show internal directories.
Click to hide internal directories.