daoctl

package
v0.2.85 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CacheHookHandler = gdb.HookHandler{
	Update: cleanCache[gdb.HookUpdateInput],
	Insert: cleanCache[gdb.HookInsertInput],
	Delete: cleanCache[gdb.HookDeleteInput],
	Select: func(ctx context.Context, in *gdb.HookSelectInput) (result gdb.Result, err error) {
		conf := gdb.CacheOption{
			Duration: time.Hour * 24,
			Name:     in.Table,
			Force:    false,
		}
		table := gstr.Replace(in.Table, "\"", "")
		for _, cacheConf := range sys_consts.Global.OrmCacheConf {
			if cacheConf.TableName == table {
				conf.Duration = time.Second * (time.Duration)(cacheConf.ExpireSeconds)
				conf.Force = cacheConf.Force
			}
		}
		in.Model.Cache(conf)
		result, err = in.Next(ctx)
		return
	},
}

Functions

func Delete added in v0.2.85

func Delete(model *gdb.Model) (rowsAffected int64)

func DeleteWithError added in v0.2.85

func DeleteWithError(model *gdb.Model) (rowsAffected int64, err error)

func Find

func Find[T any](db *gdb.Model, orderBy []sys_model.OrderBy, searchFields ...sys_model.FilterInfo) (response *sys_model.CollectRes[T], err error)

func GetAll

func GetAll[T any](db *gdb.Model, info *sys_model.Pagination) (response *sys_model.CollectRes[*T], err error)

func GetById

func GetById[T any](model *gdb.Model, id int64) *T

func GetByIdWithError added in v0.2.48

func GetByIdWithError[T any](model *gdb.Model, id int64) (*T, error)

func Insert added in v0.2.83

func Insert(model *gdb.Model, data ...interface{}) (lastInsertId int64, rowsAffected int64)

func InsertIgnore added in v0.2.83

func InsertIgnore(model *gdb.Model, data ...interface{}) (lastInsertId int64, rowsAffected int64)

func InsertIgnoreWithError added in v0.2.83

func InsertIgnoreWithError(model *gdb.Model, data ...interface{}) (lastInsertId int64, rowsAffected int64, err error)

func InsertWithError added in v0.2.83

func InsertWithError(model *gdb.Model, data ...interface{}) (lastInsertId int64, rowsAffected int64, err error)

func Query

func Query[T any](db *gdb.Model, searchFields *sys_model.SearchParams, IsExport bool) (response *sys_model.CollectRes[T], err error)

func RemoveQueryCache

func RemoveQueryCache(db gdb.DB, prefix string)

func Save added in v0.2.83

func Save(model *gdb.Model, data ...interface{}) (lastInsertId int64, rowsAffected int64)

func SaveWithError added in v0.2.83

func SaveWithError(model *gdb.Model, data ...interface{}) (lastInsertId int64, rowsAffected int64, err error)

func Scan added in v0.2.83

func Scan[T any](model *gdb.Model) *T

func ScanList added in v0.2.83

func ScanList[T any](model *gdb.Model, bindToAttrName string, relationAttrNameAndFields ...string) *T

func ScanListWithError added in v0.2.83

func ScanListWithError[T any](model *gdb.Model, bindToAttrName string, relationAttrNameAndFields ...string) (*T, error)

func ScanWithError added in v0.2.83

func ScanWithError[T any](model *gdb.Model) (*T, error)

func Update added in v0.2.83

func Update(model *gdb.Model, dataAndWhere ...interface{}) (rowsAffected int64)

func UpdateWithError added in v0.2.83

func UpdateWithError(model *gdb.Model, dataAndWhere ...interface{}) (rowsAffected int64, err error)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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