controllers/Group.js
function afterFindTeams(err, teamData){
		var teamList = {};

		// Load teams and assing it's key as it's id
		teamData.forEach(function(team){
			teamList[team.id] = team;
		});

		// Includes team object in 'table' data
		data.forEach(function(group){

			// console.log(group);
			// Go trough all the table adding key 'team' with team data
			_.forEach(group.table, function(row){
				row.team = teamList[row.teamId];
			});
		});

		// Includes team object in 'match' data
		data.forEach(function(group){

			// console.log(group);
			// Go trough all the table adding key 'team' with team data
			_.forEach(group.matches, function(row){
				row.teamA = teamList[row.teamAId];
				row.teamB = teamList[row.teamBId];
			});
		});

		next(data);
	}
function afterFindTeams(err, teamData){
		var teamList = {};

		// Load teams and assing it's key as it's id
		teamData.forEach(function(team){
			teamList[team.id] = team;
		});

		// Includes team object in 'table' data
		data.forEach(function(group){

			// console.log(group);
			// Go trough all the table adding key 'team' with team data
			_.forEach(group.table, function(row){
				row.team = teamList[row.teamId];
			});
		});

		// Includes team object in 'match' data
		data.forEach(function(group){

			// console.log(group);
			// Go trough all the table adding key 'team' with team data
			_.forEach(group.matches, function(row){
				row.teamA = teamList[row.teamAId];
				row.teamB = teamList[row.teamBId];
			});
		});

		next(data);
	}
function afterFindTeams ( err , teamData ) { var teamList = { } ; // Load teams and assing it's key as it's id teamData . forEach ( function ( team ) { teamList [ team . id ] = team ; } ) ; // Includes team object in 'table' data data . forEach ( function ( group ) { // console.log(group); // Go trough all the table adding key 'team' with team data _ . forEach ( group . table , function ( row ) { row . team = teamList [ row . teamId ] ; } ) ; } ) ; // Includes team object in 'match' data data . forEach ( function ( group ) { // console.log(group); // Go trough all the table adding key 'team' with team data _ . forEach ( group . matches , function ( row ) { row . teamA = teamList [ row . teamAId ] ; row . teamB = teamList [ row . teamBId ] ; } ) ; } ) ; next ( data ) ; }
Associate keys with teams
Associate keys with teams