update.go 740 B

123456789101112131415
  1. package template
  2. var Update = `
  3. func (m *default{{.upperStartCamelObject}}Model) Update(data {{.upperStartCamelObject}}) error {
  4. {{if .withCache}}{{.primaryCacheKey}}
  5. _, err := m.Exec(func(conn sqlx.SqlConn) (result sql.Result, err error) {
  6. query := fmt.Sprintf("update %s set %s where {{.originalPrimaryKey}} = ?", m.table, {{.lowerStartCamelObject}}RowsWithPlaceHolder)
  7. return conn.Exec(query, {{.expressionValues}})
  8. }, {{.primaryKeyVariable}}){{else}}query := fmt.Sprintf("update %s set %s where {{.originalPrimaryKey}} = ?", m.table, {{.lowerStartCamelObject}}RowsWithPlaceHolder)
  9. _,err:=m.conn.Exec(query, {{.expressionValues}}){{end}}
  10. return err
  11. }
  12. `
  13. var UpdateMethod = `Update(data {{.upperStartCamelObject}}) error`