aboutsummaryrefslogtreecommitdiff
path: root/pkg/database
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/database')
-rw-r--r--pkg/database/sql/user.go18
1 files changed, 7 insertions, 11 deletions
diff --git a/pkg/database/sql/user.go b/pkg/database/sql/user.go
index 2ec8622..0c503c2 100644
--- a/pkg/database/sql/user.go
+++ b/pkg/database/sql/user.go
@@ -158,20 +158,16 @@ func (self *UserRepository) Create(ctx context.Context, createUser *repository.C
}
func (self *UserRepository) Update(ctx context.Context, id uint, update *repository.UpdateUser) error {
- user := &User{
- Model: gorm.Model{
- ID: id,
- },
- Username: update.Username,
- Name: update.Name,
- IsAdmin: update.IsAdmin,
- Path: update.Path,
- }
-
result := self.db.
WithContext(ctx).
+ Model(&User{}).
Omit("password").
- Updates(user)
+ Where("id = ?", id).
+ Update("username", update.Username).
+ Update("name", update.Name).
+ Update("is_admin", update.IsAdmin).
+ Update("path", update.Path)
+
if result.Error != nil {
return wrapError(result.Error)
}