MCPcopy Index your code
hub / github.com/TruthHun/BookStack / SetIncreAndDecre

Function SetIncreAndDecre

models/base.go:62–74  ·  view source on GitHub ↗

设置增减 @param table 需要处理的数据表 @param field 字段 @param condition 条件 @param incre 是否是增长值,true则增加,false则减少 @param step 增或减的步长

(table string, field string, condition string, incre bool, step ...int)

Source from the content-addressed store, hash-verified

60//@param incre 是否是增长值,true则增加,false则减少
61//@param step 增或减的步长
62func SetIncreAndDecre(table string, field string, condition string, incre bool, step ...int) (err error) {
63 mark := "-"
64 if incre {
65 mark = "+"
66 }
67 s := 1
68 if len(step) > 0 {
69 s = step[0]
70 }
71 sql := fmt.Sprintf("update %v set %v=%v%v%v where %v", table, field, field, mark, s, condition)
72 _, err = orm.NewOrm().Raw(sql).Exec()
73 return
74}
75
76type SitemapDocs struct {
77 DocumentId int

Callers 5

ReadMethod · 0.92
ReadMethod · 0.92
StarMethod · 0.85
AddCommentsMethod · 0.85
DeleteMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected