async function deleteDepartment() {
    let departments = await db.query('SELECT id, name FROM department');
    departments.push({ id: null, name: "Cancel" });

    inquirer.prompt([
        {
            name: "depName",
            type: "list",
            message: "delete which department?",
            choices: departments.map(obj => obj.name)
        }
    ]).then(response => {
        if (response.depName != "Cancel") {
            let uselessDepartment = departments.find(obj => obj.name === response.depName);
            db.query("DELETE FROM department WHERE id=?", uselessDepartment.id);
            console.log("\x1b[32m", `${response.depName} was removed. Please reassign associated roles.`);
        }
        runApp();
    })
}
// Remove a department from the database
Remove a department from the database
Remove a department from the database
async function deleteDepartment() {
    let departments = await db.query('SELECT id, name FROM department');
    departments.push({ id: null, name: "Cancel" });
    inquirer.prompt([
        {
            name: "depName",
            type: "list",
            message: "delete which department?",
            choices: departments.map(obj => obj.name)
        }
    ]).then(response => {
        if (response.depName != "Cancel") {
            let uselessDepartment = departments.find(obj => obj.name === response.depName);
            db.query("DELETE FROM department WHERE id=?", uselessDepartment.id);
            console.log("\x1b[32m", `${response.depName} was removed. Please reassign associated roles.`);
        }
        runApp();
    })
}
async function deleteDepartment ( ) { let departments = await db . query ( 'SELECT id, name FROM department' ) ; departments . push ( { id : null , name : "Cancel" } ) ; inquirer . prompt ( [ { name : "depName" , type : "list" , message : "delete which department?" , choices : departments . map ( obj => obj . name ) } ] ) . then ( response => { if ( response . depName != "Cancel" ) { let uselessDepartment = departments . find ( obj => obj . name === response . depName ) ; db . query ( "DELETE FROM department WHERE id=?" , uselessDepartment . id ) ; console . log ( "\x1b[32m" , ` ${ response . depName } ` ) ; } runApp ( ) ; } ) }
Remove a department from the database
Remove a department from the database