dao

package
v0.0.0-...-ae01125 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 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 Dao

type Dao[M MODEL] struct {
	Ctx context.Context
	DB  *gorm.DB
}

func (*Dao[M]) Clone

func (d *Dao[M]) Clone(db *gorm.DB) *Dao[M]

func (*Dao[M]) DeleteManyByIDs

func (d *Dao[M]) DeleteManyByIDs(ids []int64) (int64, error)

DeleteManyByIDs 根据 IDs 批量删除

func (*Dao[M]) Find

func (d *Dao[M]) Find(page, pageSize int) ([]*M, int64, error)

Find 查询

func (*Dao[M]) GetManyByIDs

func (d *Dao[M]) GetManyByIDs(ids []int64) ([]*M, error)

GetManyByIDs 根据 IDs 批量查询

func (*Dao[M]) GetOneByID

func (d *Dao[M]) GetOneByID(id int64) (*M, error)

GetOneByID 根据 ID 单条查询

func (*Dao[M]) InsertMany

func (d *Dao[M]) InsertMany(data []*M) error

InsertMany 插入多条数据

func (*Dao[M]) InsertOne

func (d *Dao[M]) InsertOne(data *M) error

InsertOne 插入一条数据

func (*Dao[M]) UpdateByID

func (d *Dao[M]) UpdateByID(id int64, values map[string]any) (int64, error)

UpdateByID 根据 ID 更新数据

type IDao

type IDao[M MODEL] interface {
	GetOneByID(id int64) (*M, error)
	GetManyByIDs(ids []int64) ([]*M, error)
	InsertOne(i *M) error
	InsertMany(ips []*M) error
	UpdateByID(id int64, values map[string]any) (int64, error)
	DeleteManyByIDs(ids []int64) (int64, error)
	Find(page, pageSize int) ([]*M, int64, error)
}

IDao 数据访问层

func NewDao

func NewDao[M MODEL](ctx context.Context, db *gorm.DB) IDao[M]

NewDao 创建数据访问层

type MODEL

type MODEL any

Jump to

Keyboard shortcuts

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