basescopes

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DESC    = "DESC"
	ASC     = "ASC"
	LIKE    = "LIKE"
	BETWEEN = "BETWEEN"
	AND     = "AND"
	OR      = "OR"
)

Variables

This section is empty.

Functions

func GetTx

func GetTx(ctx context.Context, db *gorm.DB) *gorm.DB

GetTx 从上下文中获取tx

func WithTx

func WithTx(ctx context.Context, tx *gorm.DB) context.Context

WithTx 上下文中设置tx

Types

type Field

type Field string
const (
	BaseFieldID        Field = "id"
	BaseFieldCreatedAt Field = "created_at"
	BaseFieldUpdatedAt Field = "updated_at"
	BaseFieldDeletedAt Field = "deleted_at"
	BaseFieldStatus    Field = "status"
	BaseFieldName      Field = "name"
	BaseFieldRemark    Field = "remark"
	BaseFieldCreateBy  Field = "create_by"
	BaseFieldTitle     Field = "title"
	BaseFieldUserId    Field = "user_id"
)

func (Field) Format

func (f Field) Format(str ...string) Field

Format string

func (Field) String

func (f Field) String() string

String string

type ScopeMethod

type ScopeMethod = func(db *gorm.DB) *gorm.DB

func BetweenColumn

func BetweenColumn(column Field, min, max any) ScopeMethod

BetweenColumn 通过字段名和值列表进行查询

func CreatedAtDesc

func CreatedAtDesc() ScopeMethod

CreatedAtDesc 按创建时间倒序

func DeleteAtGT0

func DeleteAtGT0() ScopeMethod

DeleteAtGT0 删除时间大于0

func DeletedAtDesc

func DeletedAtDesc() ScopeMethod

DeletedAtDesc 按删除时间倒序

func IdGT

func IdGT(id uint32) ScopeMethod

IdGT idGT

func InIds

func InIds(ids ...uint32) ScopeMethod

InIds id列表

func NameEQ

func NameEQ(name string) ScopeMethod

NameEQ 名称相等

func NameIn

func NameIn(names ...string) ScopeMethod

NameIn 名称列表

func NameLike

func NameLike(name string) ScopeMethod

NameLike 名称

func NotInIds

func NotInIds(ids ...uint32) ScopeMethod

NotInIds id列表

func StatusEQ

func StatusEQ(status vobj.Status) ScopeMethod

StatusEQ 状态

func StatusNotEQ

func StatusNotEQ(status vobj.Status) ScopeMethod

StatusNotEQ 状态

func TitleLike

func TitleLike(title string) ScopeMethod

TitleLike 标题

func UpdateAtDesc

func UpdateAtDesc() ScopeMethod

UpdateAtDesc 按更新时间倒序

func WhereInColumn

func WhereInColumn[T any](column Field, values ...T) ScopeMethod

WhereInColumn 通过字段名和值列表进行查询

func WhereLikeKeyword

func WhereLikeKeyword(keyword string, columns ...Field) ScopeMethod

WhereLikeKeyword 前后缀模糊查询

func WhereLikePrefixKeyword

func WhereLikePrefixKeyword(keyword string, columns ...Field) ScopeMethod

WhereLikePrefixKeyword 前缀模糊查询

func WhereLikeSuffixKeyword

func WhereLikeSuffixKeyword(keyword string, columns ...Field) ScopeMethod

WhereLikeSuffixKeyword 后缀模糊查询

func WithCreateBy

func WithCreateBy(ctx context.Context) ScopeMethod

WithCreateBy 创建人查询

func WithTrashed

func WithTrashed(isDelete bool) ScopeMethod

WithTrashed 查询已删除的记录

func WithUserId

func WithUserId(ctx context.Context) ScopeMethod

WithUserId 创建人查询

type TxContext

type TxContext struct{}

Jump to

Keyboard shortcuts

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