function dropDB() {
    nano.db.destroy(nameDB, function (err) {
        if (err && err.statusCode != 404) {
            logger_1.logger.log('error', `When destroying ${nameDB} database : \n`);
            throw err;
        }
        nano.db.create(nameDB, function (err) {
            if (err) {
                logger_1.logger.log('error', `During creation of the database '${nameDB}' : \n`);
                throw err;
            }
            logger_1.logger.log('success', `Database ${nameDB} created \n`);
            if (program.test) {
                // calling tests from ./test/tests.warehouse.js
                warehouseTests();
            }
            else {
                emitter.emit('created');
            }
        });
    });
}
function dropDB() {
    nano.db.destroy(nameDB, function (err) {
        if (err && err.statusCode != 404) {
            logger_1.logger.log('error', `When destroying ${nameDB} database : \n`);
            throw err;
        }
        nano.db.create(nameDB, function (err) {
            if (err) {
                logger_1.logger.log('error', `During creation of the database '${nameDB}' : \n`);
                throw err;
            }
            logger_1.logger.log('success', `Database ${nameDB} created \n`);
            if (program.test) {
                
                warehouseTests();
            }
            else {
                emitter.emit('created');
            }
        });
    });
}
function dropDB ( ) { nano . db . destroy ( nameDB , function ( err ) { if ( err && err . statusCode != 404 ) { logger_1 . logger . log ( 'error' , ` ${ nameDB } \n ` ) ; throw err ; } nano . db . create ( nameDB , function ( err ) { if ( err ) { logger_1 . logger . log ( 'error' , ` ${ nameDB } \n ` ) ; throw err ; } logger_1 . logger . log ( 'success' , ` ${ nameDB } \n ` ) ; if ( program . test ) { // calling tests from ./test/tests.warehouse.js warehouseTests ( ) ; } else { emitter . emit ( 'created' ) ; } } ) ; } ) ; }
/*
couchDB database creation part.
First, we check if a database with the name specified already exists. If yes,
this database will be destroy before creating the new one (with the same name).
/ * couchDB database creation part . First we check if a database with the name specified already exists . If yes this database will be destroy before creating the new one ( with the same name ) .