db_repo

package
v0.0.0-...-6c1bb8a Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2021 License: MIT Imports: 0 Imported by: 0

README

使用示例

user_demo 为例:

// 查询:多条 + 分页 
page := 2
num := 2
offset := (page - 1) * num

user, err = user_demo_repo.NewQueryBuilder().
    WhereIdNotIn([]int32{1, 2, 3}).
    WhereUserName(db_repo.EqualPredicate, "tom").
    Limit(num).
    Offset(offset).
    QueryAll(u.db.GetDbR().WithContext(ctx.RequestContext()))

// 查询:总数
count, err := user_demo_repo.NewQueryBuilder().
    WhereIdNotIn([]int32{1, 2, 3}).
    WhereUserName(db_repo.EqualPredicate, "tom").
    Count(u.db.GetDbR().WithContext(ctx.RequestContext()))

// 查询:单条
user, err = user_demo_repo.NewQueryBuilder().
    WhereUserName(db_repo.EqualPredicate, "tom").
    QueryOne(u.db.GetDbR().WithContext(ctx.RequestContext()))

// 创建
model := user_demo_repo.NewModel()
model.UserName = user.UserName
model.NickName = user.NickName
model.Mobile = user.Mobile

id, err = model.Create(u.db.GetDbW().WithContext(ctx.RequestContext()))

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EqualPredicate              = Predicate("=")
	NotEqualPredicate           = Predicate("<>")
	GreaterThanPredicate        = Predicate(">")
	GreaterThanOrEqualPredicate = Predicate(">=")
	SmallerThanPredicate        = Predicate("<")
	SmallerThanOrEqualPredicate = Predicate("<=")
	LikePredicate               = Predicate("LIKE")
)

Functions

This section is empty.

Types

type Predicate

type Predicate string

Predicate is a string that acts as a condition in the where clause

Jump to

Keyboard shortcuts

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