async function updateEmployeeRole() {
    let [employees] = await db.query(`SELECT * FROM employees`);
    let [roles] = await db.query(`SELECT * FROM roles`);
    await inquirer
        .prompt([
            {
                type: 'list',
                name: 'employee',
                message: "Which employee's role would you like to update?",
                choices: employees.map((emp) => {
                    return {
                        name: `${emp.first_name} ${emp.last_name}`,
                        value: emp.id
                    };
                }),
            },
            {
                type: 'list',
                name: 'role',
                message: "Which role do you want to assign to the selected employee?",
                choices: roles.map((role) => {
                    return {
                        name: role.title,
                        value: role.id
                    };
                }),
            }
        ])
        .then(async (ans) => {
            await db.query(`UPDATE employees SET role_id = ${ans.role} WHERE id = ${ans.employee}`);
            console.log(`Role has been updated`);

        })
        .catch((err) => console.log(err));

    promptUser();
}
// Function to update an employee's role
Function to update an employee's role
Function to update an employee ' s role
async function updateEmployeeRole() {
    let [employees] = await db.query(`SELECT * FROM employees`);
    let [roles] = await db.query(`SELECT * FROM roles`);
    await inquirer
        .prompt([
            {
                type: 'list',
                name: 'employee',
                message: "Which employee's role would you like to update?",
                choices: employees.map((emp) => {
                    return {
                        name: `${emp.first_name} ${emp.last_name}`,
                        value: emp.id
                    };
                }),
            },
            {
                type: 'list',
                name: 'role',
                message: "Which role do you want to assign to the selected employee?",
                choices: roles.map((role) => {
                    return {
                        name: role.title,
                        value: role.id
                    };
                }),
            }
        ])
        .then(async (ans) => {
            await db.query(`UPDATE employees SET role_id = ${ans.role} WHERE id = ${ans.employee}`);
            console.log(`Role has been updated`);
        })
        .catch((err) => console.log(err));
    promptUser();
}
async function updateEmployeeRole ( ) { let [ employees ] = await db . query ( ` ` ) ; let [ roles ] = await db . query ( ` ` ) ; await inquirer . prompt ( [ { type : 'list' , name : 'employee' , message : "Which employee's role would you like to update?" , choices : employees . map ( ( emp ) => { return { name : ` ${ emp . first_name } ${ emp . last_name } ` , value : emp . id } ; } ) , } , { type : 'list' , name : 'role' , message : "Which role do you want to assign to the selected employee?" , choices : roles . map ( ( role ) => { return { name : role . title , value : role . id } ; } ) , } ] ) . then ( async ( ans ) => { await db . query ( ` ${ ans . role } ${ ans . employee } ` ) ; console . log ( ` ` ) ; } ) . catch ( ( err ) => console . log ( err ) ) ; promptUser ( ) ; }
Function to update an employee's role
Function to update an employee ' s role