models

package
v0.0.0-...-26b160e Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

@Time : 2018/8/15 19:05 @Author : kenny zhu @File : base.go @Software: GoLand @Others: model base operation @refer:github.com/go-tango/wego/blob/master/models/base.go.

@Time : 2018/8/15 19:05 @Author : kennyzhu @File : base.go @Software: GoLand @Others: create by xorm reverse mysql command.

@Time : 2018/8/16 9:55 @Author : kenny zhu @File : tables.go @Software: GoLand @Others: Sharding tables' operations

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotExist = errors.New("not exist")
)

Functions

func CreateIndexes

func CreateIndexes(createIndexesSql string) error

Create indexes.

func CreateTables

func CreateTables(createTablesSql string) error

add other ops for all models.. Create tables for QReader, this will drop them first, you may lost data if the tables are already exists.

func Find

func Find(limit, start int, objs interface{}) error

find limit objects. objs 为slice的指针或Map指针,即为查询后返回的结果...

func GetById

func GetById(id int64, obj interface{}) error

Get object by primary key id

func Init

func Init(isProMode bool, logPath string)

need test pro-mode ..

func IsExist

func IsExist(obj interface{}) bool

根据结构体中已有的非空数据来判断是否存在...

func ORM

func ORM() *xorm.Engine

func ShardFind

func ShardFind(id int64, limit, start int, objs interface{}) error

Shard find limit objects. ShardGetTable support array.

func ShardGetById

func ShardGetById(id int64, obj interface{}) error

engine.Table("user").Select("user.*, detail.*").

Join("INNER", "detail", "detail.user_id = user.id").
Where("user.name = ?", name).Limit(10, 0).
Find(&users)

Get object by primary key id

func ShardGetTable

func ShardGetTable(tableNameOrBean interface{}, suffixKey int64) *xorm.Session

func ShardIsExist

func ShardIsExist(id int64, obj interface{}) bool

根据结构体中已有的非空数据来判断是否存在...

func SyncAllTables

func SyncAllTables() error

tables synced..

Types

type ModelFinder

type ModelFinder interface {
	Object() interface{}
}

type Preferences

type Preferences struct {
	User  int    `xorm:"not null pk autoincr INT(10)"`
	Name  string `xorm:"not null VARCHAR(32)"`
	Value string `xorm:"not null VARCHAR(64)"`
}

func (*Preferences) String

func (m *Preferences) String() string

Directories

Path Synopsis
@Time : 2018/9/26 16:21 @Author : kenny zhu @File : sample_impl.go @Software: GoLand @Others: 此文件需要用proteus工具生成对应的micro server文件...
@Time : 2018/9/26 16:21 @Author : kenny zhu @File : sample_impl.go @Software: GoLand @Others: 此文件需要用proteus工具生成对应的micro server文件...

Jump to

Keyboard shortcuts

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