Documentation ¶
Index ¶
- type BaseDBHandler
- func (b *BaseDBHandler[T]) Create(tx *gorm.DB, model *T) (*T, error)
- func (b *BaseDBHandler[T]) Delete(tx *gorm.DB, idField string, idValue interface{}) error
- func (b *BaseDBHandler[T]) GetDB(tx *gorm.DB) *gorm.DB
- func (b *BaseDBHandler[T]) GetDBWithoutTx() *gorm.DB
- func (b *BaseDBHandler[T]) GetList(condition interface{}, pageSize, page int) ([]T, uint64, error)
- func (b *BaseDBHandler[T]) GetOne(condition interface{}) (*T, error)
- func (b *BaseDBHandler[T]) Update(tx *gorm.DB, model *T) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseDBHandler ¶
BaseDBHandler 提供了一个基础结构体,包含 GetDB 方法
func (*BaseDBHandler[T]) Create ¶ added in v0.0.21
func (b *BaseDBHandler[T]) Create(tx *gorm.DB, model *T) (*T, error)
Create 创建记录
func (*BaseDBHandler[T]) Delete ¶ added in v0.0.21
func (b *BaseDBHandler[T]) Delete(tx *gorm.DB, idField string, idValue interface{}) error
Delete 删除记录
func (*BaseDBHandler[T]) GetDB ¶
func (b *BaseDBHandler[T]) GetDB(tx *gorm.DB) *gorm.DB
GetDB 提供数据库连接或事务
func (*BaseDBHandler[T]) GetDBWithoutTx ¶
func (b *BaseDBHandler[T]) GetDBWithoutTx() *gorm.DB
GetDBWithoutTx 提供基础数据库连接
func (*BaseDBHandler[T]) GetList ¶ added in v0.0.21
func (b *BaseDBHandler[T]) GetList(condition interface{}, pageSize, page int) ([]T, uint64, error)
GetList 获取记录列表,支持分页
func (*BaseDBHandler[T]) GetOne ¶ added in v0.0.21
func (b *BaseDBHandler[T]) GetOne(condition interface{}) (*T, error)
GetOne 获取单条记录
Click to show internal directories.
Click to hide internal directories.