code: func UpdateTeamMember(cmd *m.UpdateTeamMemberCommand) error {
  	return inTransaction(func(sess *DBSession) error {
  		member, err := getTeamMember(sess, cmd.OrgId, cmd.TeamId, cmd.UserId)
  		if err != nil {
  			return err
  		}
  
  		if cmd.ProtectLastAdmin {
  			_, err := isLastAdmin(sess, cmd.OrgId, cmd.TeamId, cmd.UserId)
  			if err != nil {
  				return err
  			}
  		}
  
  		if cmd.Permission != m.PERMISSION_ADMIN { // make sure we don't get invalid permission levels in store
  			cmd.Permission = 0
  		}
  
  		member.Permission = cmd.Permission
  		_, err = sess.Cols("permission").Where("org_id=? and team_id=? and user_id=?", cmd.OrgId, cmd.TeamId, cmd.UserId).Update(member)
  
  		return err
  	})
  }
docs: // UpdateTeamMember updates a team member