function deleteDroneCredentials(req, res){
    var name = req.params.dronename;

    var query = "DELETE FROM DRONES WHERE \"name\" = ?";
    dashDB.query(query, [name], function(err, response){
        if(err) {
            logger.error("[drones.delete]: Couldn't delete drone: " + name);
            logger.error(err.message);
            res.status(400).send("Couldn't delete drone");
        } else{
            logger.info("Drone " + name + " successfully deleted from SQL database. Maybe.");

            MQTT.client.unregisterDevice('pi', name).then (function onSuccess (response) {
                logger.info("[drones.delete]: Device " + name + " successfully deleted from MQTT broker");
                req.session.drones.splice( req.session.drones.indexOf(name), 1);
                res.status(200).send("Drone " + name + " was successfully deleted");

            }, function onError (error) {
                logger.error("[drones.insert]: Device " + name + " was NOT deleted from MQTT broker");
                if(error.headers.status == 404) {
                    logger.error("[drones.delete]: 404, Device was not found.");
                } else {
                    logger.error("[drones.delete]: " + error.headers.status);
                }
                res.status(400).send("Drone " + name + " was NOT deleted");
            });

            deleteCloudantDatabases(name);
        }
    });


}
/**
 * Delete user credentials from SQL database
 * @param req {Object} The request from the client
 * @param req.params.username {String} Username of the client
 * @param res {Object} The response for the client
 */
Delete user credentials from SQL database
@param req {Object} The request from the client
@param req.params.username {String} Username of the client
@param res {Object} The response for the client
Delete user credentials from SQL database @param req { Object } The request from the client @param req . params . username { String } Username of the client @param res { Object } The response for the client
function deleteDroneCredentials(req, res){
    var name = req.params.dronename;
    var query = "DELETE FROM DRONES WHERE \"name\" = ?";
    dashDB.query(query, [name], function(err, response){
        if(err) {
            logger.error("[drones.delete]: Couldn't delete drone: " + name);
            logger.error(err.message);
            res.status(400).send("Couldn't delete drone");
        } else{
            logger.info("Drone " + name + " successfully deleted from SQL database. Maybe.");
            MQTT.client.unregisterDevice('pi', name).then (function onSuccess (response) {
                logger.info("[drones.delete]: Device " + name + " successfully deleted from MQTT broker");
                req.session.drones.splice( req.session.drones.indexOf(name), 1);
                res.status(200).send("Drone " + name + " was successfully deleted");
            }, function onError (error) {
                logger.error("[drones.insert]: Device " + name + " was NOT deleted from MQTT broker");
                if(error.headers.status == 404) {
                    logger.error("[drones.delete]: 404, Device was not found.");
                } else {
                    logger.error("[drones.delete]: " + error.headers.status);
                }
                res.status(400).send("Drone " + name + " was NOT deleted");
            });
            deleteCloudantDatabases(name);
        }
    });
}
function deleteDroneCredentials ( req , res ) { var name = req . params . dronename ; var query = "DELETE FROM DRONES WHERE \"name\" = ?" ; dashDB . query ( query , [ name ] , function ( err , response ) { if ( err ) { logger . error ( "[drones.delete]: Couldn't delete drone: " + name ) ; logger . error ( err . message ) ; res . status ( 400 ) . send ( "Couldn't delete drone" ) ; } else { logger . info ( "Drone " + name + " successfully deleted from SQL database. Maybe." ) ; MQTT . client . unregisterDevice ( 'pi' , name ) . then ( function onSuccess ( response ) { logger . info ( "[drones.delete]: Device " + name + " successfully deleted from MQTT broker" ) ; req . session . drones . splice ( req . session . drones . indexOf ( name ) , 1 ) ; res . status ( 200 ) . send ( "Drone " + name + " was successfully deleted" ) ; } , function onError ( error ) { logger . error ( "[drones.insert]: Device " + name + " was NOT deleted from MQTT broker" ) ; if ( error . headers . status == 404 ) { logger . error ( "[drones.delete]: 404, Device was not found." ) ; } else { logger . error ( "[drones.delete]: " + error . headers . status ) ; } res . status ( 400 ) . send ( "Drone " + name + " was NOT deleted" ) ; } ) ; deleteCloudantDatabases ( name ) ; } } ) ; }
Delete user credentials from SQL database
 @param req {Object} The request from the client
 @param req.params.username {String} Username of the client
 @param res {Object} The response for the client
Delete user credentials from SQL database @param req { Object } The request from the client @param req . params . username { String } Username of the client @param res { Object } The response for the client