pkg

package
v0.0.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseDBHandler

type BaseDBHandler[T any] struct {
	DB *gorm.DB
}

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 获取单条记录

func (*BaseDBHandler[T]) Update added in v0.0.21

func (b *BaseDBHandler[T]) Update(tx *gorm.DB, model *T) error

Update 更新记录

Directories

Path Synopsis
middleware

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL