lib/elevator-engine/elevator-engine.js
function(config, floors, ascending, logger, levelController, callback) {
    var self = this;

    //Itterate migrations files
    async.eachSeries(floors, function(floor, callback) {
        var parameters = new FloorWorkerParameters(config, logger, floor);
        var floorWorker = require(floor.filePath);
        var directionText = (ascending === true) ? 'Up' : 'Down';
        
        //Checkf if function is available in migration file
        if(floorWorker['on' + directionText]) {
            async.waterfall([
                function(callback) {
                    floorWorker['on' + directionText](parameters, function(error) {
                        if(error) {
                            logger.error('>>>> Stuck at floor ' + floor.getLongName());
                        } else {
                            logger.info('>>>> Migrating ' + directionText.toLowerCase() + ' floor: ' + floor.getLongName());
                        }
                        return callback(error);
                    });                
                },
                function(callback) {
                    levelController.saveCurrentLevel(Level.create(floor.identifier), function(error) {
                        if(error) {
                            logger.error('>>>> Stuck at floor ' + floor.identifier + '. Failed to store the current level');
                        }
                        return callback(error);                    
                    });
                }
            ], function(error) {
                return callback(error);                    
            })
        } else {
            return callback(Errors.generalError('>>>> Invalid floor ' + floor.filePath));
        }
    }, function(error) {
        return callback(error);
    })
}
function(config, floors, ascending, logger, levelController, callback) {
    var self = this;

    //Itterate migrations files
    async.eachSeries(floors, function(floor, callback) {
        var parameters = new FloorWorkerParameters(config, logger, floor);
        var floorWorker = require(floor.filePath);
        var directionText = (ascending === true) ? 'Up' : 'Down';
        
        //Checkf if function is available in migration file
        if(floorWorker['on' + directionText]) {
            async.waterfall([
                function(callback) {
                    floorWorker['on' + directionText](parameters, function(error) {
                        if(error) {
                            logger.error('>>>> Stuck at floor ' + floor.getLongName());
                        } else {
                            logger.info('>>>> Migrating ' + directionText.toLowerCase() + ' floor: ' + floor.getLongName());
                        }
                        return callback(error);
                    });                
                },
                function(callback) {
                    levelController.saveCurrentLevel(Level.create(floor.identifier), function(error) {
                        if(error) {
                            logger.error('>>>> Stuck at floor ' + floor.identifier + '. Failed to store the current level');
                        }
                        return callback(error);                    
                    });
                }
            ], function(error) {
                return callback(error);                    
            })
        } else {
            return callback(Errors.generalError('>>>> Invalid floor ' + floor.filePath));
        }
    }, function(error) {
        return callback(error);
    })
}
function ( config , floors , ascending , logger , levelController , callback ) { var self = this ; //Itterate migrations files async . eachSeries ( floors , function ( floor , callback ) { var parameters = new FloorWorkerParameters ( config , logger , floor ) ; var floorWorker = require ( floor . filePath ) ; var directionText = ( ascending === true ) ? 'Up' : 'Down' ; //Checkf if function is available in migration file if ( floorWorker [ 'on' + directionText ] ) { async . waterfall ( [ function ( callback ) { floorWorker [ 'on' + directionText ] ( parameters , function ( error ) { if ( error ) { logger . error ( '>>>> Stuck at floor ' + floor . getLongName ( ) ) ; } else { logger . info ( '>>>> Migrating ' + directionText . toLowerCase ( ) + ' floor: ' + floor . getLongName ( ) ) ; } return callback ( error ) ; } ) ; } , function ( callback ) { levelController . saveCurrentLevel ( Level . create ( floor . identifier ) , function ( error ) { if ( error ) { logger . error ( '>>>> Stuck at floor ' + floor . identifier + '. Failed to store the current level' ) ; } return callback ( error ) ; } ) ; } ] , function ( error ) { return callback ( error ) ; } ) } else { return callback ( Errors . generalError ( '>>>> Invalid floor ' + floor . filePath ) ) ; } } , function ( error ) { return callback ( error ) ; } ) }
Migrate an array of migration files
@param config
@param floors
@param ascending
@param logger
@param levelController - Object derived from BaseLevelController to do custom level storage
@param callback(error)
Migrate an array of migration files