async function UpdateEmployeeManager(){
    let employees =  await connection.queryPromise("SELECT * FROM employee ")
        
        
    employees = employees.map(employee=>{
         return {
            name: employee.first_name +" " + employee.last_name,
            value: employee.id
        }
    })
    inquirer
    .prompt([
      {
        name: "employee_name",
        type: "list",
        message: "Which employee's manager you want to update?",
        choices:employees
      },
      {
        name: "employee_new_manager",
        type: "list",
        message: "What's the new manager for that employee?",
        choices:employees
      }
    ])
    .then(function (answer) {
      // when finished prompting, update new employee manager into the database
      console.log("Updating new manager for the employee...\n");
      var query = connection.query(
        "UPDATE employee SET ? WHERE ?",
        [
            {
              manager_id: answer.employee_new_manager
            },
            {
              id: answer.employee_name
            }
          ],
        function (err, res) {
          if (err) throw err;
          console.log("New manager of the employee was updated successfully!");
        }
      );
    });

}
// 11. BASIC-UPDATE EMPLOYEE MANAGER
11. BASIC-UPDATE EMPLOYEE MANAGER
11 . BASIC - UPDATE EMPLOYEE MANAGER
async function UpdateEmployeeManager(){
    let employees =  await connection.queryPromise("SELECT * FROM employee ")
    employees = employees.map(employee=>{
         return {
            name: employee.first_name +" " + employee.last_name,
            value: employee.id
        }
    })
    inquirer
    .prompt([
      {
        name: "employee_name",
        type: "list",
        message: "Which employee's manager you want to update?",
        choices:employees
      },
      {
        name: "employee_new_manager",
        type: "list",
        message: "What's the new manager for that employee?",
        choices:employees
      }
    ])
    .then(function (answer) {
      console.log("Updating new manager for the employee...\n");
      var query = connection.query(
        "UPDATE employee SET ? WHERE ?",
        [
            {
              manager_id: answer.employee_new_manager
            },
            {
              id: answer.employee_name
            }
          ],
        function (err, res) {
          if (err) throw err;
          console.log("New manager of the employee was updated successfully!");
        }
      );
    });
}
async function UpdateEmployeeManager ( ) { let employees = await connection . queryPromise ( "SELECT * FROM employee " ) employees = employees . map ( employee => { return { name : employee . first_name + " " + employee . last_name , value : employee . id } } ) inquirer . prompt ( [ { name : "employee_name" , type : "list" , message : "Which employee's manager you want to update?" , choices : employees } , { name : "employee_new_manager" , type : "list" , message : "What's the new manager for that employee?" , choices : employees } ] ) . then ( function ( answer ) { console . log ( "Updating new manager for the employee...\n" ) ; var query = connection . query ( "UPDATE employee SET ? WHERE ?" , [ { manager_id : answer . employee_new_manager } , { id : answer . employee_name } ] , function ( err , res ) { if ( err ) throw err ; console . log ( "New manager of the employee was updated successfully!" ) ; } ) ; } ) ; }
11.
11 .
// when finished prompting, update new employee manager into the database