Documentation ¶
Index ¶
- func Count(tx *gorm.DB, model interface{}, options ...QueryOption) (int, error)
- func Create(tx *gorm.DB, model interface{}) error
- func Delete(tx *gorm.DB, model interface{}, limit int, options ...QueryOption) error
- func DeleteByID(tx *gorm.DB, model interface{}, id int, options ...QueryOption) error
- func DeleteOne(tx *gorm.DB, model interface{}, options ...QueryOption) error
- func GetByID(tx *gorm.DB, model interface{}, id int, options ...QueryOption) error
- func GetOne(tx *gorm.DB, model interface{}, options ...QueryOption) error
- func List(tx *gorm.DB, modelArray interface{}, options ...QueryOption) error
- func ListWithCount(tx *gorm.DB, modelArray interface{}, options ...QueryOption) (int, error)
- func NewDB(dbHost string, dbPort int, dbName, dbUser, dbPass string) *gorm.DB
- func SoftDeleteByID(tx *gorm.DB, model interface{}, id int, options ...QueryOption) error
- func SoftDeleteOne(tx *gorm.DB, model interface{}, options ...QueryOption) error
- func UpdateByID(tx *gorm.DB, model interface{}, id int, options ...QueryOption) error
- func UpdateOne(tx *gorm.DB, model interface{}, options ...QueryOption) error
- type Option
- type QueryOption
- func With(o Option) QueryOption
- func WithCondition(query string, args ...interface{}) QueryOption
- func WithLimit(offset, limit int) QueryOption
- func WithNotDeleted() QueryOption
- func WithOrder(order string) QueryOption
- func WithPage(page, pageSize int) QueryOption
- func WithPreload(column string, conditions ...interface{}) QueryOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Count ¶
func Count(tx *gorm.DB, model interface{}, options ...QueryOption) (int, error)
Count 查询数据量
func Delete ¶
func Delete(tx *gorm.DB, model interface{}, limit int, options ...QueryOption) error
Delete 删除数据 limit 限制删除条数,防止误删,取 -1 则不限制
func DeleteByID ¶
func DeleteByID(tx *gorm.DB, model interface{}, id int, options ...QueryOption) error
DeleteByID 按ID删除数据
func DeleteOne ¶
func DeleteOne(tx *gorm.DB, model interface{}, options ...QueryOption) error
DeleteOne 删除一条数据
func GetByID ¶
func GetByID(tx *gorm.DB, model interface{}, id int, options ...QueryOption) error
GetByID 按ID查询
func GetOne ¶
func GetOne(tx *gorm.DB, model interface{}, options ...QueryOption) error
GetOne 查询一条数据
func ListWithCount ¶
func ListWithCount(tx *gorm.DB, modelArray interface{}, options ...QueryOption) (int, error)
ListWithCount 查询列表及数据量
func SoftDeleteByID ¶
func SoftDeleteByID(tx *gorm.DB, model interface{}, id int, options ...QueryOption) error
SoftDeleteByID 按ID软删除数据
func SoftDeleteOne ¶
func SoftDeleteOne(tx *gorm.DB, model interface{}, options ...QueryOption) error
SoftDeleteOne 软删除一条数据
func UpdateByID ¶
func UpdateByID(tx *gorm.DB, model interface{}, id int, options ...QueryOption) error
UpdateByID 按ID更新数据,不支持级联更新
Types ¶
type QueryOption ¶
type QueryOption func(config *queryConfig)
QueryOption 查询选型
func With ¶
func With(o Option) QueryOption
func WithCondition ¶
func WithCondition(query string, args ...interface{}) QueryOption
WithCondition 查询条件
func WithPreload ¶
func WithPreload(column string, conditions ...interface{}) QueryOption
WithPreload 懒加载
Click to show internal directories.
Click to hide internal directories.