forked from si3nloong/sqlike
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.go
52 lines (44 loc) · 980 Bytes
/
update.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package sql
import (
"github.com/RevenueMonster/sqlike/sqlike/primitive"
)
// UpdateStmt :
type UpdateStmt struct {
Database string
Table string
Conditions primitive.Group
Values []primitive.KV
Sorts []interface{}
Max uint
}
// Update :
func Update(tables ...interface{}) *UpdateStmt {
stmt := new(UpdateStmt)
return stmt.Update(tables...)
}
// Update :
func (stmt *UpdateStmt) Update(fields ...interface{}) *UpdateStmt {
return stmt
}
// Where :
func (stmt *UpdateStmt) Where(fields ...interface{}) *UpdateStmt {
// stmt.Conditions = expr.And(fields...)
return stmt
}
// Set :
func (stmt *UpdateStmt) Set(values ...primitive.KV) *UpdateStmt {
stmt.Values = append(stmt.Values, values...)
return stmt
}
// OrderBy :
func (stmt *UpdateStmt) OrderBy(fields ...interface{}) *UpdateStmt {
stmt.Sorts = fields
return stmt
}
// Limit :
func (stmt *UpdateStmt) Limit(num uint) *UpdateStmt {
if num > 0 {
stmt.Max = num
}
return stmt
}