models

package
v0.0.0-...-75bc1fc Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIdsEmpty = errors.New("ids is empty")
)

Functions

This section is empty.

Types

type Model

type Model struct {
	DiName string //依赖注入的别名
}

*

  • 基础model

func (*Model) Delete

func (m *Model) Delete(id interface{}, bean interface{}) (int64, error)

*

  • 删除单个记录 -- 如果有开启delete特性,会触发软删除
  • @param id 主键ID
  • @param bean 数据结构实体

func (*Model) DeleteMulti

func (m *Model) DeleteMulti(ids []interface{}, bean interface{}) (int64, error)

*

  • 查询多个主键ID的记录
  • @param ids 主键ID分片
  • @param bean 数据结构实体

func (*Model) GetDb

func (m *Model) GetDb(args ...string) *xorm.EngineGroup

*

func (*Model) GetList

func (m *Model) GetList(beans interface{}, sql string, values []interface{}, args ...interface{}) (err error)

*

  • 查询多个主键ID的记录
  • @param beans 数据结构实体分片 eg. &banners 其中 banners := make([]*Banner, 0)
  • @params sql eg. "age > ? or name = ?"
  • @params values eg. []interfaces{}{30, "hts"}
  • @Param []int limit 可选 eg. []int{} 不限量 []int{30} 前30个 []int{30, 20} 从第20个后的前30个
  • @param string order 可选 eg. "id desc" 单个 "uid desc,status asc" 多个

func (*Model) GetMulti

func (m *Model) GetMulti(ids []interface{}, beans interface{}) error

*

  • 查询多个主键ID的记录
  • @param ids 主键ID分片
  • @param beans 数据结构实体分片

func (*Model) GetOne

func (m *Model) GetOne(id interface{}, bean interface{}) (has bool, err error)

*

  • 查询主键ID的记录
  • @param id 主键ID
  • @param bean 数据结构实体
  • @return has 是否有记录

func (*Model) Insert

func (m *Model) Insert(beans ...interface{}) (int64, error)

*

  • 插入记录
  • @param beans... 可支持插入连续多个记录

func (*Model) Update

func (m *Model) Update(id interface{}, bean interface{}, mustColumns ...string) (int64, error)

*

  • 更新某个主键ID的数据
  • @param id 主键ID
  • @param bean 数据结构实体
  • @param mustColumns... 因为默认Update只更新非0,非”“,非bool的字段,需要配合此字段
  • @param

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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