How should the problem of updating data be optimized?

  public type User = {
    userID: Principal; 
    userName: Text;
    userType: UserType;
    userFollowers: Nat; 
    userFollowing: Nat; 
    userAvatarURL: Text; 
    userBackgroundURL: Text;
    userTwitterURL: Text;
    userEmailURL: Text; 
    lastLoginTime: Int; 

public shared({ caller }) func setUserName( userName: Text): () {
    let userInfo : ?T.User = userToData.get(caller);
    switch(userInfo) {
        case (null) {};
        case (?userInfo) {
          // userInfo.userName := userName;
        let s: T.User = {
            userID = userInfo.userID; 
            userName = userName;
            userType = userInfo.userType; 
            userFollowers = userInfo.userFollowers; 
            userFollowing = userInfo.userFollowing; 
            userAvatarURL = userInfo.userAvatarURL;
            userBackgroundURL = userInfo.userBackgroundURL; 
            userTwitterURL = userInfo.userTwitterURL; 
            userEmailURL = userInfo.userEmailURL; 
            lastLoginTime = userInfo.lastLoginTime; 


In this case “expected mutable assignment target” occurs if the commented out part “userInfo.userName := userNamet]” is used
But if I set “type User userName” to “var” it will solve this problem but it will trigger another problem “shared function has non-shared parameter type”
Do we have another way to update "userInfo.userName " using simple writing?