Documentation ¶
Index ¶
- func Copy() func(db *gorm.DB) *gorm.DB
- func Count[T any](db *gorm.DB, fn func(tx *gorm.DB) *gorm.DB) (int64, error)
- func Create(value any, batchSize ...int) func(db *gorm.DB) (int64, error)
- func DB(db *gorm.DB) (*sql.DB, error)
- func DBClose(db *gorm.DB) error
- func DBPing(db *gorm.DB) error
- func DBStats(db *gorm.DB) (sql.DBStats, error)
- func DefaultLogger() func(conf *gorm.Config) *gorm.Config
- func Delete[T any](fn func(tx *gorm.DB) *gorm.DB) func(db *gorm.DB) (int64, error)
- func DeleteAndReturn[T any](fn func(tx *gorm.DB) *gorm.DB, field ...string) func(db *gorm.DB) ([]T, int64, error)
- func DeleteById[T any](ids ...uint) func(db *gorm.DB) (int64, error)
- func Exec(db *gorm.DB, sql string, values ...any) (int64, error)
- func Find[T any](fn func(tx *gorm.DB) *gorm.DB) func(db *gorm.DB) ([]T, error)
- func FindById[T any](ids ...uint) func(db *gorm.DB) ([]T, error)
- func FindByWhere[T any](where string, args ...any) func(db *gorm.DB) ([]T, error)
- func First[T any](fn func(tx *gorm.DB) *gorm.DB) func(db *gorm.DB) (T, error)
- func FirstById[T any](ids ...uint) func(db *gorm.DB) (T, error)
- func FirstByWhere[T any](where string, args ...any) func(db *gorm.DB) (T, error)
- func IgnoreErrRecordNotFound[T any](v T, err error) (T, error)
- func Last[T any](fn func(tx *gorm.DB) *gorm.DB) func(db *gorm.DB) (T, error)
- func LastById[T any](ids ...uint) func(db *gorm.DB) (T, error)
- func LastByWhere[T any](where string, args ...any) func(db *gorm.DB) (T, error)
- func LogLevel(logLevel string) logger.LogLevel
- func LogWriter(isStdout bool, logFile string, logLevel logger.LogLevel, ...) (logger.Interface, error)
- func Logger(out io.Writer, logConf ...logger.Config) func(conf *gorm.Config) *gorm.Config
- func New() func(db *gorm.DB) *gorm.DB
- func NewMySQL(dsn string, logWriter logger.Interface) (*gorm.DB, error)
- func One[T any](fn func(tx *gorm.DB) *gorm.DB) func(db *gorm.DB) (T, error)
- func OneById[T any](ids ...uint) func(db *gorm.DB) (T, error)
- func OneByWhere[T any](where string, args ...any) func(db *gorm.DB) (T, error)
- func Paginate[T any](page int, pageSize int, fn func(tx *gorm.DB) *gorm.DB) func(db *gorm.DB) (*Pages, error)
- func Pipeline(db *gorm.DB, fn func(tx *gorm.DB) error) error
- func Pluck[T any, F FieldType](db *gorm.DB, fn func(tx *gorm.DB) *gorm.DB, field string) ([]F, error)
- func PrepareStmt(b bool) func(conf *gorm.Config) *gorm.Config
- func Query[T any](db *gorm.DB, sql string, values ...any) (T, error)
- func SelectModelField(b bool) func(conf *gorm.Config) *gorm.Config
- func SkipTx(b bool) func(conf *gorm.Config) *gorm.Config
- func ToSQL(db *gorm.DB, fn func(tx *gorm.DB) *gorm.DB) string
- func Tx(db *gorm.DB, fn func(tx *gorm.DB) error) error
- func Update[T any](db *gorm.DB, fn func(tx *gorm.DB) *gorm.DB, data map[string]any) (int64, error)
- func UpdateAndReturn[T any](db *gorm.DB, fn func(tx *gorm.DB) *gorm.DB, data map[string]any, ...) ([]T, int64, error)
- func WithAllowGlobalUpdate(b bool) func(db *gorm.DB) *gorm.DB
- func WithContext(ctx context.Context) func(db *gorm.DB) *gorm.DB
- func WithCreateBatchSize(i int) func(db *gorm.DB) *gorm.DB
- func WithDefaultLogger() func(db *gorm.DB) *gorm.DB
- func WithError(err error) func(db *gorm.DB) *gorm.DB
- func WithJoin(typ, table, tableJoinField, mainTableField string) string
- func WithLeftJoin(table, tableJoinField, mainTableField string) string
- func WithLogger(out io.Writer, logConf ...logger.Config) func(db *gorm.DB) *gorm.DB
- func WithPrepareStmt(b bool) func(db *gorm.DB) *gorm.DB
- func WithRightJoin(table, tableJoinField, mainTableField string) string
- func WithSelectModeField(b bool) func(db *gorm.DB) *gorm.DB
- func WithSkipTx(b bool) func(db *gorm.DB) *gorm.DB
- func WithTestRun(b bool) func(db *gorm.DB) *gorm.DB
- func WithTime(f func() time.Time) func(db *gorm.DB) *gorm.DB
- func WithUnscoped(db *gorm.DB) *gorm.DB
- type Day
- type FieldType
- type JSON
- type Model
- type Page
- type Pages
- type SQLStmt
- type Time
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteAndReturn ¶
func FindByWhere ¶
func FirstByWhere ¶
func IgnoreErrRecordNotFound ¶
IgnoreErrRecordNotFound 忽略 ErrRecordNotFound 错误 当 First、Last、Take 方法找不到记录时,GORM 会返回 ErrRecordNotFound 错误
func SelectModelField ¶
SelectModelField QueryFields 模式会根据当前 model 的所有字段名称进行 select
func UpdateAndReturn ¶
func WithAllowGlobalUpdate ¶
WithAllowGlobalUpdate 不允许进行全局 update/execFunc,操作会返回 ErrMissingWhereClause 错误
func WithContext ¶
WithContext 持续会话模式
func WithLeftJoin ¶
func WithLogger ¶
func WithPrepareStmt ¶
WithPrepareStmt 所有 DB 操作都会创建并缓存预编译语句
func WithRightJoin ¶
func WithTestRun ¶
WithTestRun 生成 SQL 但不执行。 它可以用于准备或测试生成的 SQL
Types ¶
type Day ¶
Day format json time field by myself
func (Day) MarshalJSON ¶
MarshalJSON on JSONTime format Time field with %Y-%m-%d %H:%M:%S
type Page ¶
type Page struct { Page *int `json:"page" form:"page" bind:"numeric"` // 当前页,默认为1 PageSize *int `json:"pageSize",form:"pageSize" bind:"numeric"` // 分页条目数据,默认10 Total *int64 `json:"total"` // 查询总数量 }
Page 通用分页 @Description 通用分页查条件
type Time ¶
Time format json time field by myself
func (Time) MarshalJSON ¶
MarshalJSON on JSONTime format Time field with %Y-%m-%d %H:%M:%S
Click to show internal directories.
Click to hide internal directories.