Documentation ¶
Index ¶
- Constants
- func BuildCommonCondition(tx *gorm.DB, obj interface{}, req dtos.BaseSearchConditionQuery) *gorm.DB
- func MakeLikeParams(str string) string
- type ClientSQLite
- type DataObject
- type DialectorType
- type GormClient
- func (c *GormClient) AssociationsDeleteObject(object DataObject) (err error)
- func (c *GormClient) AssociationsUpdateObject(object DataObject) (err error)
- func (c *GormClient) BatchUpdate(fields, conflictFields, updateFields []string, tableName string, ...) error
- func (c *GormClient) Close()
- func (c *GormClient) CloseSession()
- func (c *GormClient) CreateObject(object DataObject) (err error)
- func (c *GormClient) DeleteObject(object DataObject) (err error)
- func (c *GormClient) ExecSqlWithTransaction(funcs ...func(db *gorm.DB) error) error
- func (c *GormClient) ExistObject(do DataObject) (exist bool, err error)
- func (c *GormClient) GetObject(obCond DataObject, object DataObject) (err error)
- func (c *GormClient) GetObjects(doCond DataObject, do DataObject, likeParam *LikeQueryParam, ...) (list []interface{}, count int64, err error)
- func (c *GormClient) GetPreloadObject(obCond DataObject, object DataObject) (err error)
- func (c *GormClient) InitTable(dos ...DataObject) error
- func (c *GormClient) UpdateObject(object DataObject) (err error)
- type GormWriter
- type LikeQueryParam
- type OrderQueryParam
Constants ¶
View Source
const ( // 顺序排序 AscOrder = "asc" // 倒序排序 DescOrder = "desc" // 默认排序字段 DefaultOrderField = "modified" OrderFieldCreated = "created" // 批量创建的每条sql最大条数 CreateBatchSize = 500 // 批量更新的每条sql最大条数 UpdateBatchSize = 10000 )
Variables ¶
This section is empty.
Functions ¶
func BuildCommonCondition ¶
func MakeLikeParams ¶
Types ¶
type ClientSQLite ¶
type ClientSQLite interface { CloseSession() // 关闭连接 Close() // 初始化建表操作 InitTable(dos ...DataObject) error // 添加数据 CreateObject(do DataObject) error // 判断数据是否存在 ExistObject(do DataObject) (bool, error) // 删除数据 DeleteObject(do DataObject) error // 更新数据 UpdateObject(do DataObject) error // 关联更新 AssociationsUpdateObject(do DataObject) error // 关联删除 AssociationsDeleteObject(do DataObject) error // 查询单个数据 GetObject(doCond DataObject, do DataObject) error // 预加载查询单个数据 GetPreloadObject(doCond DataObject, do DataObject) error // 查询列表数据 GetObjects(doCond DataObject, do DataObject, likeParam *LikeQueryParam, order *OrderQueryParam, offset, limit int) ([]interface{}, int64, error) // 批量更新数据 BatchUpdate(fields, conflictFields, updateFields []string, tableName string, records [][]interface{}) error //事物相关 ExecSqlWithTransaction(funcs ...func(db *gorm.DB) error) error }
type DataObject ¶
type DataObject interface { TableName() string Get() interface{} }
type DialectorType ¶
type DialectorType string
const ( DIALECTOR_MYSQL DialectorType = "mysql" DIALECTOR_PGSQL DialectorType = "postgres" DIALECTOR_SQLITE DialectorType = "sqlite" )
type GormClient ¶
func NewGormClient ¶
func NewGormClient(config dtos.Configuration, lc logger.LoggingClient) (*GormClient, error)
func (*GormClient) AssociationsDeleteObject ¶
func (c *GormClient) AssociationsDeleteObject(object DataObject) (err error)
AssociationsDeleteObject 关联删除
func (*GormClient) AssociationsUpdateObject ¶
func (c *GormClient) AssociationsUpdateObject(object DataObject) (err error)
AssociationsUpdateObject 关联更新
func (*GormClient) BatchUpdate ¶
func (c *GormClient) BatchUpdate(fields, conflictFields, updateFields []string, tableName string, records [][]interface{}) error
fields: 全字段名称列表 conflictFields: 唯一字段名称列表 updateFields: 更新字段名称列表 record: 更新数据列表
func (*GormClient) Close ¶
func (c *GormClient) Close()
func (*GormClient) CloseSession ¶
func (c *GormClient) CloseSession()
func (*GormClient) CreateObject ¶
func (c *GormClient) CreateObject(object DataObject) (err error)
CreateObject 添加
func (*GormClient) DeleteObject ¶
func (c *GormClient) DeleteObject(object DataObject) (err error)
DeleteObject 删除
func (*GormClient) ExecSqlWithTransaction ¶
func (c *GormClient) ExecSqlWithTransaction(funcs ...func(db *gorm.DB) error) error
func (*GormClient) ExistObject ¶
func (c *GormClient) ExistObject(do DataObject) (exist bool, err error)
判断是否存在
func (*GormClient) GetObject ¶
func (c *GormClient) GetObject(obCond DataObject, object DataObject) (err error)
GetObject 获取结果
func (*GormClient) GetObjects ¶
func (c *GormClient) GetObjects(doCond DataObject, do DataObject, likeParam *LikeQueryParam, order *OrderQueryParam, offset, limit int) (list []interface{}, count int64, err error)
条件查询
func (*GormClient) GetPreloadObject ¶
func (c *GormClient) GetPreloadObject(obCond DataObject, object DataObject) (err error)
GetPreloadObject 预加载
func (*GormClient) InitTable ¶
func (c *GormClient) InitTable(dos ...DataObject) error
func (*GormClient) UpdateObject ¶
func (c *GormClient) UpdateObject(object DataObject) (err error)
UpdateObject 更新数据
type GormWriter ¶
type GormWriter struct {
// contains filtered or unexported fields
}
func (*GormWriter) Printf ¶
func (gl *GormWriter) Printf(s string, values ...interface{})
type LikeQueryParam ¶
模糊查询参数
type OrderQueryParam ¶
排序查询参数
Click to show internal directories.
Click to hide internal directories.