orm

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model struct {
	// contains filtered or unexported fields
}

func (*Model) Connect

func (p *Model) Connect(connectName string) *Model

指定哪个连接 connectName 必须是已经是在config/db配置好了的

func (*Model) ConnectAdd

func (p *Model) ConnectAdd(connectName string, connect Connect) *Model

指定哪个连接 并将传入的连接放入配置项, 下一次可直接使用

func (*Model) Count

func (p *Model) Count() (count int64, err error)

func (*Model) Delete

func (p *Model) Delete() (count int64, err error)

func (*Model) ExecSql

func (p *Model) ExecSql(sql string, args ...interface{}) (affectCount int64, lastInsertId int64, err error)

func (*Model) Field

func (p *Model) Field(fields ...string) *Model

func (*Model) First

func (p *Model) First() (has bool, err error)

func (*Model) Get

func (p *Model) Get() (has bool, err error)

查询返回一个数组

func (*Model) GetAutoSetField

func (p *Model) GetAutoSetField(method string) (needSet map[string]interface{}, err error)

取得在method操作时需要自动填充的字段与值

func (*Model) Insert

func (p *Model) Insert() (err error)

func (*Model) InsertMap

func (p *Model) InsertMap(maps map[string]interface{}) (pk int64, err error)

func (*Model) Limit

func (p *Model) Limit(skip int, len int) *Model

func (*Model) Model

func (p *Model) Model(m interface{}) *Model

func (*Model) OrderBy

func (p *Model) OrderBy(field string, desc bool) *Model

func (*Model) Page

func (p *Model) Page(page int, pageSize int) (pageData Page, has bool, err error)

func (*Model) PageWithOutTotal

func (p *Model) PageWithOutTotal(page int, pageSize int) (pageData Page, has bool, err error)

func (*Model) QuerySql

func (p *Model) QuerySql(sql string, args ...interface{}) (has bool, data []map[string]interface{}, err error)

原始方法 查询sql返回map

func (*Model) QueryToMap

func (p *Model) QueryToMap() (has bool, data []map[string]interface{}, err error)

查询主方法,返回[]Map原数据给get和first使用

func (*Model) Reset

func (p *Model) Reset() *Model

清除已经有的Where,fields,limit,order条件

func (*Model) Sqls

func (p *Model) Sqls() []string

读取执行的sql,用于调试,获取后将清空

func (*Model) Table

func (p *Model) Table(table string) *Model

指定表

func (*Model) Update

func (p *Model) Update() (count int64, err error)

func (*Model) UpdateMap

func (p *Model) UpdateMap(mapper map[string]interface{}) (count int64, err error)

func (*Model) Where

func (p *Model) Where(condition string, values ...interface{}) *Model

eg:(`Id`= ? AND `Name` = ?,1,"bysir")

the field name is used struct's field name, u need wapper it use “

func (*Model) WhereIn

func (p *Model) WhereIn(field string, params ...interface{}) *Model

type Page

type Page struct {
	Total     int64 `json:"total,omitempty"`
	PageTotal int   `json:"page_total,omitempty"`
	Page      int   `json:"page,omitempty"`
	PageSize  int   `json:"page_size,omitempty"`
}

用于返回page

Jump to

Keyboard shortcuts

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