function createCloudantDatabases(name){
    name = name.toLowerCase();

    var toCreate = [
        "_images", "_audio", "_sensorlog", "_eventlog", "_positionlog"
    ];

    for(var i=0; i<toCreate.length; i++){
        (function(databaseName){
            cloudant.db.create(databaseName, function(err, response){
                if(err){
                    logger.error("Couldn't create database "+ databaseName + " for drone " + name);
                    logger.error(err.message);
                } else { // Check for if ok not true
                    logger.info("Created database " + databaseName);
                    var database = cloudant.use(databaseName);
                    
                    var index = {
                        name : 'time',
                        type : 'json',
                        ddoc : name + '_indexDesignDoc',
                        index : {
                            fields : ['time']
                        }
                    };

                    database.index(index, function(err, response){
                        if(err){
                            logger.error("Error " + err);
                            return;
                        }
                        logger.info(response.result + " " + databaseName + " index.");
                    });


                }
            })
        })(name + toCreate[i]);

    }
}
/**
 * Create Cloudant databases for given droneName
 * @param name {String} Provided drone name
 */
Create Cloudant databases for given droneName
@param name {String} Provided drone name
Create Cloudant databases for given droneName @param name { String } Provided drone name
function createCloudantDatabases(name){
    name = name.toLowerCase();
    var toCreate = [
        "_images", "_audio", "_sensorlog", "_eventlog", "_positionlog"
    ];
    for(var i=0; i<toCreate.length; i++){
        (function(databaseName){
            cloudant.db.create(databaseName, function(err, response){
                if(err){
                    logger.error("Couldn't create database "+ databaseName + " for drone " + name);
                    logger.error(err.message);
                } else { 
                    logger.info("Created database " + databaseName);
                    var database = cloudant.use(databaseName);
                    var index = {
                        name : 'time',
                        type : 'json',
                        ddoc : name + '_indexDesignDoc',
                        index : {
                            fields : ['time']
                        }
                    };
                    database.index(index, function(err, response){
                        if(err){
                            logger.error("Error " + err);
                            return;
                        }
                        logger.info(response.result + " " + databaseName + " index.");
                    });
                }
            })
        })(name + toCreate[i]);
    }
}
function createCloudantDatabases ( name ) { name = name . toLowerCase ( ) ; var toCreate = [ "_images" , "_audio" , "_sensorlog" , "_eventlog" , "_positionlog" ] ; for ( var i = 0 ; i < toCreate . length ; i ++ ) { ( function ( databaseName ) { cloudant . db . create ( databaseName , function ( err , response ) { if ( err ) { logger . error ( "Couldn't create database " + databaseName + " for drone " + name ) ; logger . error ( err . message ) ; } else { logger . info ( "Created database " + databaseName ) ; var database = cloudant . use ( databaseName ) ; var index = { name : 'time' , type : 'json' , ddoc : name + '_indexDesignDoc' , index : { fields : [ 'time' ] } } ; database . index ( index , function ( err , response ) { if ( err ) { logger . error ( "Error " + err ) ; return ; } logger . info ( response . result + " " + databaseName + " index." ) ; } ) ; } } ) } ) ( name + toCreate [ i ] ) ; } }
Create Cloudant databases for given droneName
 @param name {String} Provided drone name
Create Cloudant databases for given droneName @param name { String } Provided drone name
// Check for if ok not true