orm

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTables

func CreateTables(v interface{})

请自行定

func DB

func DB() *gorm.DB

SetDB gorm对象

func DbByWhere

func DbByWhere(m interface{}, w *DbWhere) *dbByWhere

DbByWhere

func DbCount

func DbCount(model, where interface{}) int64

DbCount 数目

func DbCreate

func DbCreate(model interface{}) error

DbCreate 创建

func DbDeleteBy

func DbDeleteBy(model interface{}, where string, args ...interface{}) (count int64, err error)

DbDeleteBy 删除

func DbDeleteByIds

func DbDeleteByIds(model, ids interface{}) error

DbDeleteByIds 批量删除 ids id数组 []

func DbDeletes

func DbDeletes(value interface{}) error

DbDeletes 批量删除

func DbFind

func DbFind(out interface{}, orders ...string) error

DbFind 多个查找

func DbFindBy

func DbFindBy(out interface{}, where string, args ...interface{}) (int64, error)

DbFindBy 多个条件查找

func DbFirstBy

func DbFirstBy(out interface{}, where string, args ...interface{}) (err error)

DbFirstBy 指定条件查找

func DbFirstById

func DbFirstById(out interface{}, id uint) error

DbFirstById 查找

func DbFirstWhere

func DbFirstWhere(out, where interface{}) error

DbFirstWhere 查找

func DbPageRawScan

func DbPageRawScan(query string, obj interface{}, page, size int) (int64, error)

DbPageRawScan obj必须是数组类型

func DbSave

func DbSave(value interface{}) error

DbSave 保存

func DbTableByWhere

func DbTableByWhere(table string, w *DbWhere) *dbByWhere

func DbUpdateById

func DbUpdateById(model, id interface{}) error

DbUpdatesById 更新

func DbUpdateByIds

func DbUpdateByIds(model interface{}, ids []int, value map[string]interface{}) error

DbUpdateByIds 批量更新 ids id数组

func DbUpdateColBy

func DbUpdateColBy(model interface{}, column string, value interface{}, where string, args ...interface{}) error

func DbUpdateColById

func DbUpdateColById(model, id interface{}, column string, value interface{}) error

DbUpdateColById 单列更新

func DbUpdateColsBy

func DbUpdateColsBy(model interface{}, value map[string]interface{}, where string, args ...interface{}) error

DbUpdateColsBy 更新多列 用于0不更新

func DbUpdateModel

func DbUpdateModel(model interface{}) error

DbUpdateModel 更新

func DbUpdateModelBy

func DbUpdateModelBy(model interface{}, where string, args ...interface{}) error

DbUpdateModelBy 条件更新

func DbUpdates

func DbUpdates(model interface{}, cols ...string) error

自定义字段,用于0不更新

func DbUpdatesBy

func DbUpdatesBy(model interface{}, cols []string, where string, args ...interface{}) error

自定义字段,用于0不更新

func NewGormV2

func NewGormV2(name, address string) (db *gorm.DB, err error)

func NewPartiton

func NewPartiton(table string) *dbPart

func SetDB

func SetDB(db *gorm.DB)

SetDB gorm对象

Types

type DbPage

type DbPage struct {
	Num  int `form:"pageNum"`  // 当前页码
	Size int `form:"pageSize"` // 每页数
}

func (*DbPage) DbWhere

func (o *DbPage) DbWhere() *DbWhere

type DbWhere

type DbWhere struct {
	Wheres []wValue
	Orders []string
	Page   *DbPage
}

DbWhere 搜索条件条件

func (*DbWhere) Append

func (p *DbWhere) Append(w string, v ...interface{})

Append 添加条件

func (*DbWhere) DateRange

func (p *DbWhere) DateRange(field string, st, et string)

DateRange

func (*DbWhere) Equal

func (p *DbWhere) Equal(field string, v interface{})

Equal

func (*DbWhere) Like

func (p *DbWhere) Like(field, v string)

Like

func (*DbWhere) TimeRange

func (p *DbWhere) TimeRange(field string, st, et string)

TimeRange

type H

type H map[string]interface{}

H 多列处理

type XTablers

type XTablers interface {
	TableName() string       // 默认创建表
	TableNameOf(uint) string // 获取分区表
	TableCount() uint
}

Jump to

Keyboard shortcuts

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