Documentation ¶
Index ¶
- Variables
- func AutoMigrate(dst ...interface{})
- func AutoMigrateWithName(name string, dst ...interface{})
- func ConvertBoolValue(src any) (bool, error)
- func Db() *gorm.DB
- func GetDb(datasourceName string) *gorm.DB
- func GetDbByCtx(ctx context.Context) *gorm.DB
- func GetDbByCtxAndName(ctx context.Context, name string) *gorm.DB
- func GetTableName(db *gorm.DB, tableName string) string
- func InitDataSource(configMap map[string]Config) error
- func RowsToListMap(rows *sql.Rows) []cmap.Map[string, any]
- func ToSqlTx(db *gorm.DB) *sql.Tx
- func Transaction(ctx context.Context, f func(txCtx context.Context) error) error
- func TransactionWithDsName(ctx context.Context, datasourceName string, ...) error
- type BoolValue
- type Config
- type NullBool
- func (n NullBool) BoolValue() (*bool, error)
- func (NullBool) GormDBDataType(db *gorm.DB, _ *schema.Field) string
- func (NullBool) GormDataType() string
- func (n NullBool) MarshalJSON() ([]byte, error)
- func (n *NullBool) Scan(value any) error
- func (n *NullBool) UnmarshalJSON(data []byte) (err error)
- func (n NullBool) Value() (driver.Value, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrDatasourceNotFound = errors.New("datasource not found")
View Source
var ErrUsernameNotFound = errors.New("datasource username is empty")
Functions ¶
func AutoMigrate ¶
func AutoMigrate(dst ...interface{})
func AutoMigrateWithName ¶
func AutoMigrateWithName(name string, dst ...interface{})
func ConvertBoolValue ¶
func InitDataSource ¶
Types ¶
type Config ¶
type Config struct { // 数据库类型 Type string // 数据库url Host string // 数据库Username Username string // 数据库Password Password string // Silent 1 Error 2 Warn 3 Info 4 LogLevel int // 数据库名称 Dbname string // 连接池中最大空闲连接的数量 n <= 0 代表没有空闲 MaxIdleConns int // 打开数据库连接的最大数量 n <= 0 代表不限制 MaxOpenConns int // 连接可复用的最大时间(单位分钟) n <= 0 则不关闭连接 ConnMaxLifetime int // 连接空闲的最大时间(单位分钟) n <= 0 则不关闭连接 ConnMaxIdleTime int // 自动创建数据表 AutoMigrate bool }
type NullBool ¶
NullBool represents a bool that may be null. NullBool implements the Scanner interface it can be used as a scan destination, similar to NullString.
func (NullBool) GormDBDataType ¶
func (NullBool) GormDataType ¶
func (NullBool) MarshalJSON ¶
MarshalJSON on JSONTime format Time field with Y-m-d H:i:s
func (*NullBool) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.