Documentation ¶
Overview ¶
通用基本数据库操作
Index ¶
- func Count(model interface{}, intPrt *int64, condition interface{}, ...) error
- func Create(model interface{}) (int64, error)
- func Delete(model interface{}, PrimaryKeyID interface{}, condition interface{}, ...) (int64, error)
- func First(destModel interface{}, PrimaryKey string, selectFields []string, ...) error
- func GenerateCacheKey(params ...any) string
- func Get(destModel interface{}, selectFields []string, condition interface{}, ...) error
- func Last(destModel interface{}, PrimaryKey string, selectFields []string, ...) error
- func ListScan(l *List, model interface{}, destModels interface{})
- func QueryScan(destModel interface{}, extra interface{}, condition interface{}, ...) error
- func ReflectStructID(obj interface{}) interface{}
- func SetGlobalCacheExpire(expire int64)
- func SetOrmEngine(engineName string) error
- func SqlExec(sql interface{}, args ...interface{}) error
- func SqlQuery(sql interface{}, args ...interface{}) (resultsSlice []map[string]interface{}, err error)
- func SqlQueryScan(destModel interface{}, sql interface{}, args ...interface{}) error
- func Sync(beans ...any)
- func Update(model interface{}, fields any, condition interface{}, ...) error
- type Condition
- type DbContext
- type DbOperat
- type DbTransactionSession
- type Gorm
- func (orm *Gorm) Begin() error
- func (orm *Gorm) Commit() error
- func (orm *Gorm) Count(model interface{}, intPtr *int64, condition interface{}, args ...interface{}) error
- func (orm *Gorm) Create(model interface{}) (int64, error)
- func (orm *Gorm) Delete(model interface{}, PrimaryKeyID interface{}, condition interface{}, ...) (int64, error)
- func (orm *Gorm) First(destModel interface{}, PrimaryKey string, selectFields []string, ...) error
- func (orm *Gorm) Get(destModel interface{}, selectFields []string, condition interface{}, ...) error
- func (orm *Gorm) GetCurrentSelectFields() []string
- func (orm *Gorm) IsCurrentSelectedField(field string) bool
- func (orm *Gorm) Last(destModel interface{}, PrimaryKey string, selectFields []string, ...) error
- func (orm *Gorm) ListScan(l *List, model interface{}, destModels interface{})
- func (orm *Gorm) QueryScan(destModel interface{}, extra interface{}, condition interface{}, ...) error
- func (orm *Gorm) Rollback() error
- func (orm *Gorm) SqlExec(sql interface{}, args ...interface{}) error
- func (orm *Gorm) SqlQuery(sql interface{}, args ...interface{}) (resultsSlice []map[string]interface{}, err error)
- func (orm *Gorm) SqlQueryScan(destModel interface{}, sql interface{}, args ...interface{}) error
- func (orm *Gorm) Sync(beans ...any)
- func (orm *Gorm) Update(model interface{}, fields any, condition interface{}, ...) error
- func (orm *Gorm) Value(key any) any
- func (orm *Gorm) WithValue(key, value any)
- type List
- type ListSimple
- type Xorm
- func (orm *Xorm) Begin() error
- func (orm *Xorm) Commit() error
- func (orm *Xorm) Count(model interface{}, intPrt *int64, condition interface{}, ...) error
- func (orm *Xorm) Create(model interface{}) (int64, error)
- func (orm *Xorm) Delete(model interface{}, PrimaryKeyID interface{}, condition interface{}, ...) (int64, error)
- func (orm *Xorm) First(destModel interface{}, PrimaryKey string, selectFields []string, ...) error
- func (orm *Xorm) Get(destModel interface{}, selectFields []string, condition interface{}, ...) error
- func (orm *Xorm) GetCurrentSelectFields() []string
- func (orm *Xorm) IsCurrentSelectedField(field string) bool
- func (orm *Xorm) Last(destModel interface{}, PrimaryKey string, selectFields []string, ...) error
- func (orm *Xorm) ListScan(l *List, model interface{}, destModels interface{})
- func (orm *Xorm) QueryScan(destModel interface{}, extra interface{}, condition interface{}, ...) error
- func (orm *Xorm) Rollback() error
- func (orm *Xorm) SqlExec(sql interface{}, args ...interface{}) error
- func (orm *Xorm) SqlQuery(sql interface{}, args ...interface{}) (resultsSlice []map[string]interface{}, err error)
- func (orm *Xorm) SqlQueryScan(destModel interface{}, sql interface{}, args ...interface{}) error
- func (orm *Xorm) Sync(beans ...any)
- func (orm *Xorm) Update(model interface{}, fields any, condition interface{}, ...) error
- func (orm *Xorm) Value(key any) any
- func (orm *Xorm) WithValue(key, value any)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
func Delete(model interface{}, PrimaryKeyID interface{}, condition interface{}, conditionArgs ...interface{}) (int64, error)
删除记录
func First ¶
func First(destModel interface{}, PrimaryKey string, selectFields []string, condition interface{}, conditionArgs ...interface{}) error
获取第一条记录
func GenerateCacheKey ¶
func Get ¶
func Get(destModel interface{}, selectFields []string, condition interface{}, conditionArgs ...interface{}) error
获取记录
func Last ¶
func Last(destModel interface{}, PrimaryKey string, selectFields []string, condition interface{}, conditionArgs ...interface{}) error
获取最后条记录
func QueryScan ¶
func QueryScan(destModel interface{}, extra interface{}, condition interface{}, args ...interface{}) error
func ReflectStructID ¶
func ReflectStructID(obj interface{}) interface{}
func SetGlobalCacheExpire ¶
func SetGlobalCacheExpire(expire int64)
func SqlQuery ¶
func SqlQuery(sql interface{}, args ...interface{}) (resultsSlice []map[string]interface{}, err error)
原生sql查询
func SqlQueryScan ¶
func SqlQueryScan(destModel interface{}, sql interface{}, args ...interface{}) error
原生sql查询解析到结构体或MAP
Types ¶
type DbOperat ¶
type DbOperat interface { DbContext //获取第一条记录 First(destModel interface{}, PrimaryKey string, selectFields []string, condition interface{}, conditionArgs ...interface{}) error //获取最后一条记录 Last(destModel interface{}, PrimaryKey string, selectFields []string, condition interface{}, conditionArgs ...interface{}) error //列表查询 ListScan(l *List, model interface{}, destModels interface{}) //获取一条记录 Get(destModel interface{}, selectFields []string, condition interface{}, conditionArgs ...interface{}) error //修改记录 Update(model interface{}, fields any, condition interface{}, conditionArgs ...interface{}) error //删除记录 Delete(model interface{}, PrimaryKeyID interface{}, condition interface{}, conditionArgs ...interface{}) (int64, error) //创建记录 Create(model interface{}) (int64, error) //执行原生sql命令 SqlExec(sql interface{}, args ...interface{}) error //执行原生sql查询 SqlQuery(sql interface{}, args ...interface{}) (resultsSlice []map[string]interface{}, err error) //执行原生sql查询并将结果解析到结构体、map等结构中 SqlQueryScan(destModel interface{}, sql interface{}, args ...interface{}) error //执行根据条件查询 QueryScan(destModel interface{}, order interface{}, condition interface{}, args ...interface{}) error //获取记录数 Count(model interface{}, intPrt *int64, condition interface{}, conditionArgs ...interface{}) error //获取当前选择的字段 GetCurrentSelectFields() []string //当前是否选中该字段 IsCurrentSelectedField(field string) bool //同步结构到数据库 Sync(beans ...any) }
通用数据库基本操作接口
type DbTransactionSession ¶
事务接口
func WithContext ¶
func WithContext(ctx context.Context) (DbTransactionSession, error)
type Gorm ¶
func (*Gorm) Delete ¶
func (orm *Gorm) Delete(model interface{}, PrimaryKeyID interface{}, condition interface{}, conditionArgs ...interface{}) (int64, error)
删除记录
func (*Gorm) Get ¶
func (orm *Gorm) Get(destModel interface{}, selectFields []string, condition interface{}, conditionArgs ...interface{}) error
获取记录
func (*Gorm) GetCurrentSelectFields ¶
func (*Gorm) IsCurrentSelectedField ¶
func (*Gorm) Last ¶
func (orm *Gorm) Last(destModel interface{}, PrimaryKey string, selectFields []string, condition interface{}, conditionArgs ...interface{}) error
获取最后条记录
func (*Gorm) QueryScan ¶
func (orm *Gorm) QueryScan(destModel interface{}, extra interface{}, condition interface{}, args ...interface{}) error
执行根据条件查询
func (*Gorm) SqlQuery ¶
func (orm *Gorm) SqlQuery(sql interface{}, args ...interface{}) (resultsSlice []map[string]interface{}, err error)
原生sql查询
func (*Gorm) SqlQueryScan ¶
原生sql查询解析到结构体或MAP
type ListSimple ¶
type Xorm ¶
func (*Xorm) Count ¶
func (orm *Xorm) Count(model interface{}, intPrt *int64, condition interface{}, conditionArgs ...interface{}) error
获取记录
func (*Xorm) Delete ¶
func (orm *Xorm) Delete(model interface{}, PrimaryKeyID interface{}, condition interface{}, conditionArgs ...interface{}) (int64, error)
删除记录
func (*Xorm) Get ¶
func (orm *Xorm) Get(destModel interface{}, selectFields []string, condition interface{}, conditionArgs ...interface{}) error
获取记录
func (*Xorm) GetCurrentSelectFields ¶
func (*Xorm) IsCurrentSelectedField ¶
func (*Xorm) Last ¶
func (orm *Xorm) Last(destModel interface{}, PrimaryKey string, selectFields []string, condition interface{}, conditionArgs ...interface{}) error
获取最后条记录
func (*Xorm) QueryScan ¶
func (orm *Xorm) QueryScan(destModel interface{}, extra interface{}, condition interface{}, args ...interface{}) error
执行根据条件查询
func (*Xorm) SqlQuery ¶
func (orm *Xorm) SqlQuery(sql interface{}, args ...interface{}) (resultsSlice []map[string]interface{}, err error)
原生sql查询
func (*Xorm) SqlQueryScan ¶
原生sql查询解析到结构体或MAP
Click to show internal directories.
Click to hide internal directories.