dao

package
v1.25.4 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dao added in v1.19.22

type Dao[E any] interface {
	Insert(entity *E) error
}

type MgoDao

type MgoDao[E any] struct {
	CollectionName string
	Tag            func() string
}

MgoDao 注意使用前必须先将CollectionName赋值

func (MgoDao[E]) All

func (m MgoDao[E]) All(query bson.M) ([]E, error)

All mongo动态查询数据

func (MgoDao[E]) Delete

func (m MgoDao[E]) Delete(query bson.M) error

Delete mongo动态删除数据

func (MgoDao[E]) Insert

func (m MgoDao[E]) Insert(entity *E) error

Insert mongo动态插入数据

func (MgoDao[E]) One

func (m MgoDao[E]) One(query bson.M) (*E, error)

One mongo动态查询一条数据

func (MgoDao[E]) Pager

func (m MgoDao[E]) Pager(query bson.M, sort []string, page, size int) ([]E, *models.ResultPage, error)

Pager mongo简单分页查询数据

func (MgoDao[E]) Updates

func (m MgoDao[E]) Updates(id primitive.ObjectID, doc E) error

Updates mongo动态更新数据

type MySQLDao

type MySQLDao[E schema.Tabler] struct {
	Tag func() string
	// contains filtered or unexported fields
}

func (*MySQLDao[E]) All

func (receiver *MySQLDao[E]) All(entity E, opts ...QueryOption) ([]E, error)

All mysql动态查询数据

func (*MySQLDao[E]) Count added in v1.21.0

func (receiver *MySQLDao[E]) Count(entity E) (int64, error)

Count mysql统计记录数

func (*MySQLDao[E]) Create

func (receiver *MySQLDao[E]) Create(entity *E) error

Create mysql动态插入数据

func (*MySQLDao[E]) Debug added in v1.19.17

func (m *MySQLDao[E]) Debug() *MySQLDao[E]

func (*MySQLDao[E]) Delete

func (receiver *MySQLDao[E]) Delete(entity E) error

Delete mysql动态删除数据

func (*MySQLDao[E]) Exists added in v1.21.0

func (receiver *MySQLDao[E]) Exists(entity E) bool

Exists mysql动态查询是否存在数据

func (*MySQLDao[E]) MultiCreate

func (receiver *MySQLDao[E]) MultiCreate(entities []*E) error

MultiCreate mysql动态插入多条数据

func (*MySQLDao[E]) One

func (receiver *MySQLDao[E]) One(entity E) (*E, error)

One mysql动态查询一条数据

func (*MySQLDao[E]) Pager

func (receiver *MySQLDao[E]) Pager(conn *gorm.DB, page, size int) ([]E, *models.ResultPage, error)

Pager mysql简单分页查询数据

func (*MySQLDao[E]) Save

func (receiver *MySQLDao[E]) Save(entity *E) error

Save mysql动态保存数据

func (*MySQLDao[E]) Updates

func (receiver *MySQLDao[E]) Updates(entity *E) error

Updates mysql动态更新数据

func (*MySQLDao[E]) Where added in v1.21.0

func (m *MySQLDao[E]) Where(query interface{}, args ...interface{}) *gorm.DB

Where mysql动态查询数据

func (*MySQLDao[E]) WithContext added in v1.21.0

func (m *MySQLDao[E]) WithContext(ctx *context.Context) *MySQLDao[E]

type QueryOption added in v1.19.47

type QueryOption struct {
	Preloads []string
	OrderBy  []string
}

Jump to

Keyboard shortcuts

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