Documentation ¶
Overview ¶
Package sdgorm GORM扩展
Index ¶
- Variables
- func Create(tx *gorm.DB, row any) (int64, error)
- func CreateAndTake[T any](tx *gorm.DB, row T, q any, args ...any) (T, error)
- func CreateInBatches(tx *gorm.DB, rows any, opts *CreateInBatchesOptions) (int64, error)
- func Delete[T any](tx *gorm.DB, conds ...any) (int64, error)
- func Dial(addr Address, config *gorm.Config) (*gorm.DB, error)
- func Exec(tx *gorm.DB, q string, values ...any) (int64, error)
- func Exists[T any](tx *gorm.DB, conds ...any) (bool, error)
- func Find[T any](tx *gorm.DB, conds ...any) ([]T, error)
- func FindPaging[T any](builder func() *gorm.DB, p sdsql.Page) (*sdsql.PagingResult[T], error)
- func First[T any](tx *gorm.DB, conds ...any) (T, error)
- func Last[T any](tx *gorm.DB, conds ...any) (T, error)
- func LoggerOf(name string) gormlogger.Interface
- func Modify[T any](tx *gorm.DB, modifier func(T) T, q any, args ...any) (int64, error)
- func ModifyAndTake[T any](tx *gorm.DB, modifier func(T) T, q any, args ...any) (T, error)
- func MustMapper[M any](asPrimitive bool) func(sdjson.Object) (M, error)
- func MustMapperToAny[M any](asPrimitive bool) func(sdjson.Object) (any, error)
- func NewMapper[M any](asPrimitive bool) (func(sdjson.Object) (M, error), error)
- func NewMapperToAny[M any](asPrimitive bool) (func(sdjson.Object) (any, error), error)
- func PageScope(p sdsql.Page) func(*gorm.DB) *gorm.DB
- func Raw[T any](tx *gorm.DB, q string, values ...any) (T, error)
- func RawPaging[T any](tx *gorm.DB, selectSql string, args map[string]any, p sdsql.Page) (*sdsql.PagingResult[T], error)
- func RowExists[T any](_ T, err error) (bool, error)
- func Scan[T any](tx *gorm.DB) (T, error)
- func Take[T any](tx *gorm.DB, conds ...any) (T, error)
- func Transaction[R any](db *gorm.DB, action func(tx *gorm.DB) (R, error), opts ...*sql.TxOptions) (R, error)
- func UpdateColumns[T any](tx *gorm.DB, colVals map[string]any, q any, args ...any) (int64, error)
- func UpdateColumnsAndTake[T any](tx *gorm.DB, colVals map[string]any, q any, args ...any) (T, error)
- type Address
- type CreateInBatchesOptions
- type Schema
Constants ¶
This section is empty.
Variables ¶
View Source
var ( LoggerDiscard = gormlogger.Discard LoggerGormDefault = gormlogger.Default LoggerPlainInfo = newGormLogger(gormlogger.Info, false) LoggerPlainWarn = newGormLogger(gormlogger.Warn, false) LoggerPlainError = newGormLogger(gormlogger.Error, false) LoggerPlainSilent = newGormLogger(gormlogger.Silent, false) LoggerColorfulInfo = newGormLogger(gormlogger.Info, true) LoggerColorfulWarn = newGormLogger(gormlogger.Warn, true) LoggerColorfulError = newGormLogger(gormlogger.Error, true) LoggerColorfulSilent = newGormLogger(gormlogger.Silent, true) LoggerBuiltin = newBuiltinLogger(200 * time.Millisecond) )
View Source
var (
ErrIllegalDriver = sderr.Sentinel("illegal driver")
)
Functions ¶
func CreateInBatches ¶
func FindPaging ¶
func LoggerOf ¶
func LoggerOf(name string) gormlogger.Interface
func ModifyAndTake ¶
func MustMapperToAny ¶
func NewMapperToAny ¶
func Transaction ¶
func UpdateColumns ¶
Types ¶
type Address ¶
type Address struct { // common Driver string `json:"driver" toml:"driver" yaml:"driver"` DSN string `json:"dsn" toml:"dsn" yaml:"dsn"` Logger string `json:"logger" toml:"logger"` // mysql MySqlConn gorm.ConnPool `json:"-" toml:"-"` MySqlSkipInitializeWithVersion bool `json:"mysql_skip_initialize_with_version" toml:"mysql_skip_initialize_with_version" yaml:"mysql_skip_initialize_with_version"` MySqlDefaultStringSize uint `json:"mysql_default_string_size" toml:"mysql_default_string_size" yaml:"mysql_default_string_size"` MySqlDefaultDatetimePrecision *int `json:"mysql_default_datetime_precision" toml:"mysql_default_datetime_precision" yaml:"mysql_default_datetime_precision"` MySqlDisableDatetimePrecision bool `json:"mysql_disable_datetime_precision" toml:"mysql_disable_datetime_precision" yaml:"mysql_disable_datetime_precision"` MySqlDontSupportRenameIndex bool `json:"mysql_dont_support_rename_index" toml:"mysql_dont_support_rename_index" yaml:"mysql_dont_support_rename_index"` MySqlDontSupportRenameColumn bool `json:"mysql_dont_support_rename_column" toml:"mysql_dont_support_rename_column" yaml:"mysql_dont_support_rename_column"` // postgres PostgresConn *sql.DB `json:"-" toml:"-"` PostgresPreferSimpleProtocol bool `json:"postgres_prefer_simple_protocol" toml:"postgres_prefer_simple_protocol" yaml:"postgres_prefer_simple_protocol"` PostgresWithoutReturning bool `json:"postgres_without_returning" toml:"postgres_without_returning" yaml:"postgres_without_returning"` }
type CreateInBatchesOptions ¶
Click to show internal directories.
Click to hide internal directories.