model

package
v0.0.0-...-efd88b5 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2021 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	In         = "IN"          // 在指定枚举值范围内
	NotIn      = "NOT IN"      // 不在指定枚举值范围内
	Between    = "BETWEEN"     // 在指定范围内
	NotBetween = "NOT BETWEEN" // 不在指定范围内
	Like       = "LIKE"        // 模糊查询like
	FindINSet  = "FIND_IN_SET" // find in set
	Raw        = "RAW"         // 原样输出
	EQ         = "="           // equal 等于<=>
	NEQ        = "<>"          // not equal 不等于(!=、<>)
	GT         = ">"           // greater than 大于
	GTE        = ">="          // greater than or equal 大于等于
	LT         = "<"           // less than 小于
	LTE        = "<"           // less than or equal 小于等于
)

定义Where条件常量便于IDE追踪

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseField

type BaseField struct {
	ID        uint `gorm:"primaryKey"`
	CreatedAt uint `gorm:"autoCreateTime"`
	UpdatedAt uint `gorm:"autoCreateTime,autoUpdateTime"`
}

BaseField 通用基础字段

type Where

type Where struct {
	Field string
	Op    string
	Value interface{}
}

Where 定义where查询条件

切片Where多个条件最终SQL中将使用 AND 符拼接
- Field 查询的字段名称字符串
- Op    查询的条件符号,建议使用包内常量,全部大写[IN、NOT IN、BETWEEN、NOT BETWEEN、LIKE、FIND_IN_SET、=、<>、>=、<、<=、RAW等]
  当使用RAW时将忽略Op值,直接使用gorm提供的原生Where方法构建<注意转义特殊字符特别留意SQL注入风险>
- Value 查询的条件值,当Op为LIKE时无需添加前后的百分号<%>,方法体自动添加前后百分号

Jump to

Keyboard shortcuts

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