function initPopulateAttendanceTableFromEventTables(tableName) {

	var eventsList = [];
	var errors = [];
	var nTablesParsed = 0;
	var iterator = 0;

	// get a list of all events
	dbGetEventsList(function(rows, cols) {

		console.log('MYSQL', 'INFO', 'About to parse through', rows.length, 'tables...');
		addTableDataToArray();

		/**
		 * Select contents of each table and add to array as object
		 */
		function addTableDataToArray() {

			mysql.query('SELECT * FROM `' + rows[iterator].table_name + '`', function(err, evtRows, evtCols) {

				if(err) {
					console.log('MYSQL', 'ERR', 'An error has occurred while extracting data from table \'' + rows[iterator].table_name + '\'');
					return errors.push(err);
				}


				var evtToAdd = { table_name: rows[iterator].table_name, rows: evtRows };
				eventsList.push(evtToAdd);

				iterator++;
				nTablesParsed++;

				if(nTablesParsed >= rows.length) {
					onGetEventsList(eventsList);
				} else {
					addTableDataToArray();
				}

			});
		}

	});

	/**
	 * Callback called once eventsList has been populated with table data
	 */
	function onGetEventsList(rows) {
		console.log('MYSQL', 'INFO', 'Successfully parsed', eventsList.length, 'out of', rows.length, 'tables.');
		dbPopulateAttendanceTable(tableName, rows);

	}
}
/**
 * Init script, to be called after a connection with the database is made
 * Populates `attendance` table in database with data from each event's
 * independent table
 */
Init script, to be called after a connection with the database is made
Populates `attendance` table in database with data from each event's
independent table
Init script to be called after a connection with the database is made Populates ` attendance ` table in database with data from each event ' s independent table
function initPopulateAttendanceTableFromEventTables(tableName) {
	var eventsList = [];
	var errors = [];
	var nTablesParsed = 0;
	var iterator = 0;
	dbGetEventsList(function(rows, cols) {
		console.log('MYSQL', 'INFO', 'About to parse through', rows.length, 'tables...');
		addTableDataToArray();
		function addTableDataToArray() {
			mysql.query('SELECT * FROM `' + rows[iterator].table_name + '`', function(err, evtRows, evtCols) {
				if(err) {
					console.log('MYSQL', 'ERR', 'An error has occurred while extracting data from table \'' + rows[iterator].table_name + '\'');
					return errors.push(err);
				}
				var evtToAdd = { table_name: rows[iterator].table_name, rows: evtRows };
				eventsList.push(evtToAdd);
				iterator++;
				nTablesParsed++;
				if(nTablesParsed >= rows.length) {
					onGetEventsList(eventsList);
				} else {
					addTableDataToArray();
				}
			});
		}
	});
	function onGetEventsList(rows) {
		console.log('MYSQL', 'INFO', 'Successfully parsed', eventsList.length, 'out of', rows.length, 'tables.');
		dbPopulateAttendanceTable(tableName, rows);
	}
}
function initPopulateAttendanceTableFromEventTables ( tableName ) { var eventsList = [ ] ; var errors = [ ] ; var nTablesParsed = 0 ; var iterator = 0 ; dbGetEventsList ( function ( rows , cols ) { console . log ( 'MYSQL' , 'INFO' , 'About to parse through' , rows . length , 'tables...' ) ; addTableDataToArray ( ) ; function addTableDataToArray ( ) { mysql . query ( 'SELECT * FROM `' + rows [ iterator ] . table_name + '`' , function ( err , evtRows , evtCols ) { if ( err ) { console . log ( 'MYSQL' , 'ERR' , 'An error has occurred while extracting data from table \'' + rows [ iterator ] . table_name + '\'' ) ; return errors . push ( err ) ; } var evtToAdd = { table_name : rows [ iterator ] . table_name , rows : evtRows } ; eventsList . push ( evtToAdd ) ; iterator ++ ; nTablesParsed ++ ; if ( nTablesParsed >= rows . length ) { onGetEventsList ( eventsList ) ; } else { addTableDataToArray ( ) ; } } ) ; } } ) ; function onGetEventsList ( rows ) { console . log ( 'MYSQL' , 'INFO' , 'Successfully parsed' , eventsList . length , 'out of' , rows . length , 'tables.' ) ; dbPopulateAttendanceTable ( tableName , rows ) ; } }
Init script, to be called after a connection with the database is made
 Populates `attendance` table in database with data from each event's
 independent table
Init script to be called after a connection with the database is made Populates ` attendance ` table in database with data from each event ' s independent table
// get a list of all events /**
		 * Select contents of each table and add to array as object
		 */ /**
	 * Callback called once eventsList has been populated with table data
	 */