Skip to content

Commit

Permalink
fix:mgo delete err (#2496)
Browse files Browse the repository at this point in the history
  • Loading branch information
qinguoyi authored Aug 21, 2024
1 parent 97f4b51 commit f44a97b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/common/storage/database/mgo/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ func (u *UserMgo) DeleteUserCommand(ctx context.Context, userID string, Type int
filter := bson.M{"userID": userID, "type": Type, "uuid": UUID}

result, err := collection.DeleteOne(ctx, filter)
// when err is not nil, result might be nil
if err != nil {
return errs.Wrap(err)
}
if result.DeletedCount == 0 {
// No records found to update
return errs.Wrap(errs.ErrRecordNotFound)
Expand Down

0 comments on commit f44a97b

Please sign in to comment.