Documentation
¶
Index ¶
- func GetDB(dbName string) *gorm.DB
- type BaseDao
- func (dao *BaseDao[M, ID]) BatchCreate(ctx context.Context, ms []*M) error
- func (dao *BaseDao[M, ID]) Create(ctx context.Context, m *M) error
- func (dao *BaseDao[M, ID]) DB(ctx context.Context) *gorm.DB
- func (dao *BaseDao[M, ID]) DeleteByWhere(ctx context.Context, where string, args []any) (int64, error)
- func (dao *BaseDao[M, ID]) FindListByWhere(ctx context.Context, query string, args []any, columns ...string) ([]*M, error)
- func (dao *BaseDao[M, ID]) FindOneByWhere(ctx context.Context, where string, args []any, columns ...string) (*M, bool, error)
- func (dao *BaseDao[M, ID]) GetByPk(ctx context.Context, id ID) (*M, bool, error)
- func (dao *BaseDao[M, ID]) Transaction(ctx context.Context, fn func(ctx context.Context, tx *gorm.DB) error) error
- func (dao *BaseDao[M, ID]) UpdateByWhere(ctx context.Context, where string, args []any, data any, columns ...string) (int64, error)
- type Dao
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BaseDao ¶
type BaseDao[M any, ID comparable] struct { // contains filtered or unexported fields }
func NewBaseDao ¶
func NewBaseDao[M any, ID comparable](dbName, tableName, pkName string) *BaseDao[M, ID]
func (*BaseDao[M, ID]) BatchCreate ¶
func (*BaseDao[M, ID]) DeleteByWhere ¶
func (*BaseDao[M, ID]) FindListByWhere ¶
func (*BaseDao[M, ID]) FindOneByWhere ¶
func (*BaseDao[M, ID]) Transaction ¶
type Dao ¶
type Dao[M any, ID comparable] interface { DB(ctx context.Context) *gorm.DB Transaction(ctx context.Context, fn func(ctx context.Context, tx *gorm.DB) error) error Create(ctx context.Context, data any) error // 支持单条和批量 UpdateByWhere(ctx context.Context, where string, args []any, data any, columns ...string) error DeleteByWhere(ctx context.Context, where string, args []any) error GetByPk(ctx context.Context, id ID) (*M, bool, error) FindOneByWhere(ctx context.Context, where string, args []any, columns ...string) (*M, bool, error) FindListByWhere(ctx context.Context, where string, args []any, columns ...string) ([]*M, error) }
Click to show internal directories.
Click to hide internal directories.