controllers/Group.js
function afterFindGroups(models){
		data = models;
		completed = 0;

		if(data.length <= 0)
			return next([]);

		// Load Matches for each Group and associates
		data.forEach(function(group){

			app.models.Match.find()
				.where({'groupId': group.id})
				.sort('state DESC')
				.sort('day ASC')
				.sort('hour ASC')
				.sort('id')
				.then(function(matches){
				// Associate matches with groups
				group.matches = matches;

				// Compute scoring table for each group
				// (must be computed AFTER associating matches with it)
				group.table = group.table();

				// Callback
				loadedModel();
			});
		});
	}
function afterFindGroups(models){
		data = models;
		completed = 0;

		if(data.length <= 0)
			return next([]);

		// Load Matches for each Group and associates
		data.forEach(function(group){

			app.models.Match.find()
				.where({'groupId': group.id})
				.sort('state DESC')
				.sort('day ASC')
				.sort('hour ASC')
				.sort('id')
				.then(function(matches){
				// Associate matches with groups
				group.matches = matches;

				// Compute scoring table for each group
				// (must be computed AFTER associating matches with it)
				group.table = group.table();

				// Callback
				loadedModel();
			});
		});
	}
function afterFindGroups ( models ) { data = models ; completed = 0 ; if ( data . length <= 0 ) return next ( [ ] ) ; // Load Matches for each Group and associates data . forEach ( function ( group ) { app . models . Match . find ( ) . where ( { 'groupId' : group . id } ) . sort ( 'state DESC' ) . sort ( 'day ASC' ) . sort ( 'hour ASC' ) . sort ( 'id' ) . then ( function ( matches ) { // Associate matches with groups group . matches = matches ; // Compute scoring table for each group // (must be computed AFTER associating matches with it) group . table = group . table ( ) ; // Callback loadedModel ( ) ; } ) ; } ) ; }
After finishing search
After finishing search