tianxiaoliang commented on a change in pull request #862:
URL:
https://github.com/apache/servicecomb-service-center/pull/862#discussion_r579605775
##########
File path: datasource/mongo/account.go
##########
@@ -131,26 +130,25 @@ func (ds *DataSource) DeleteAccount(ctx context.Context,
key string) (bool, erro
return true, nil
}
-func (ds *DataSource) UpdateAccount(ctx context.Context, key string, account
*rbac.Account) error {
+func (ds *DataSource) UpdateAccount(ctx context.Context, name string, account
*rbac.Account) error {
filter := bson.M{
- ColumnAccountName: key,
+ ColumnAccountName: name,
}
update := bson.M{
"$set": bson.M{
ColumnID: account.ID,
- ColumnAccountName: account.Name,
ColumnPassword: account.Password,
ColumnRoles: account.Roles,
ColumnTokenExpirationTime: account.TokenExpirationTime,
ColumnCurrentPassword: account.CurrentPassword,
ColumnStatus: account.Status,
},
}
- result, err := client.GetMongoClient().Update(ctx, CollectionAccount,
filter, update)
+ res, err := client.GetMongoClient().Update(ctx, CollectionAccount,
filter, update, options.Update().SetUpsert(true))
Review comment:
Update().SetUpsert(true) 会导致自动新增吧?如果是的话就不合理了
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]