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