feat: update
This commit is contained in:
@@ -343,3 +343,21 @@ func (m *usersModel) Count(ctx context.Context, cond BoolExpression) (int64, err
|
||||
|
||||
return cnt.Cnt, nil
|
||||
}
|
||||
|
||||
// UpdateUsername
|
||||
func (m *usersModel) UpdateUsername(ctx context.Context, id int64, username string) error {
|
||||
tbl := table.Users
|
||||
stmt := tbl.
|
||||
UPDATE(tbl.Username).
|
||||
SET(String(username)).
|
||||
WHERE(
|
||||
tbl.ID.EQ(Int64(id)),
|
||||
)
|
||||
m.log.Infof("sql: %s", stmt.DebugSql())
|
||||
|
||||
if _, err := stmt.ExecContext(ctx, db); err != nil {
|
||||
m.log.Errorf("error updating username: %v", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user