xdbm

package module
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2019 License: MIT Imports: 3 Imported by: 0

README

xdbm

实体模型库

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetModelFields

func GetModelFields(m IModel) map[string]QueryField

获取模型查询字段定义

func GetQueryFields

func GetQueryFields(m IModel, rule string, selectFields ...interface{}) (string, [][]string)

选择查询模型字段列表

func Query added in v0.1.2

func Query(query xorm.IOrm, m IModel, rule string, selects ...interface{}) xorm.IOrm

生成查询字段及join配置

func Select added in v0.1.2

func Select(db xorm.IOrm, m IModel, rule string, selects ...interface{}) xorm.IOrm

查询模型字段

Types

type IModel

type IModel interface {
	// 表名
	TableName() string
	// 表名别名
	AliasName() string
	// 表命名
	TableAlias(alias ...string) string
	// 字段列表
	Fields() map[string]interface{}
	// 带字段别名
	Field(fieldName string) string
}

type IModelMutation

type IModelMutation interface {
	// 添加规则
	AppendRules() []string
	// 更新规则
	UpdateRules() []string
}

数据变动规则

type IModelQuery

type IModelQuery interface {
	// 允许排序字段
	AllowSortFields() map[string]bool
}

type IModelRelation

type IModelRelation interface {
	// 获取连接类型
	GetJoin() string
	// 获取关联模型
	GetModel() IModel
	// 获取关系
	GetRelation() string
	// 获取查询表达式
	GetExpress() string
	// rule
	GetRule() string
}

实体模型关系接口

func NewModelRelation

func NewModelRelation(rule string, model IModel, on string, join string, express ...string) IModelRelation

type Model

type Model struct {
	IModel
	IModelMutation
	IModelQuery
}

func (*Model) TableAlias

func (m *Model) TableAlias(alias ...string) string

type QueryField

type QueryField interface {
	// 获取规则
	GetRules() []string
	// 检查是否存在规则
	HasRule(rule string) bool
	// 获取字段查询表达式
	GetExpress() string
	// 获取关系表
	GetJoinTable() string
	GetTableAlias() string
	// 获取关系表达式
	GetJoin() []string
}

func NewQueryField

func NewQueryField(rules string, express string, joinTable string, alias string, join []string) QueryField

创建查询字段

Jump to

Keyboard shortcuts

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