code: func AddTeamMember(cmd *m.AddTeamMemberCommand) error {
  	return inTransaction(func(sess *DBSession) error {
  		if res, err := sess.Query("SELECT 1 from team_member WHERE org_id=? and team_id=? and user_id=?", cmd.OrgId, cmd.TeamId, cmd.UserId); err != nil {
  			return err
  		} else if len(res) == 1 {
  			return m.ErrTeamMemberAlreadyAdded
  		}
  
  		if _, err := teamExists(cmd.OrgId, cmd.TeamId, sess); err != nil {
  			return err
  		}
  
  		entity := m.TeamMember{
  			OrgId:      cmd.OrgId,
  			TeamId:     cmd.TeamId,
  			UserId:     cmd.UserId,
  			External:   cmd.External,
  			Created:    time.Now(),
  			Updated:    time.Now(),
  			Permission: cmd.Permission,
  		}
  
  		_, err := sess.Insert(&entity)
  		return err
  	})
  }
docs: // AddTeamMember adds a user to a team