Build a CLI application to manage company's employees using node, inquirer, and MySQL.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
# Install inquirer
npm i inquirer
# Install MySQL
npm i mysql
# Run
node index.js or npm start (using nodemon)
To get Note Taker, after downloading, you need to make sure Git Bash terminal open and looking at the correct folder. When you are within the correct location, you may type the following commands to ask her for information:
- node index.js
- Proceeds as follows:
To use this applicaion, Clone the applicaion to your local git repository or directory:
- In your terminal, git clone https://github.com/EunsooJung/Employee-Tracker.git
To start:
- Open your terminal then "node index.js"
-
Project structure
-
Source Code Check point
- ORM - EmpTrackerDB.js: Connect to MySQL Database, reset database and defined db schema.
- Models layer example - budget.js: Defined functions to Calculates the combinded salaries of all employees and by department that using the Promise.
function getTotalBudget() { return new Promise((resolve, reject) => { const query = `SELECT SUM(salary) AS 'Total Budget' FROM role, employee WHERE employee.role_id=role.id`; db.query(query, (err, results, fields) => { if (err) { reject(err); } else { resolve(results[0]['Total Budget']); } }); }); }
- View layer example: index.js using the inquirer
- import controllers into the index.js
switch (answer.action.toLowerCase()) { case 'view all employees': await displayAllEmployees();
- Controllers layer example - budget.js: Displays the total utilized budget that applied async/await
async function displayTotalBudget() { try { let totalBudget = await getTotalBudget(); // from budget model totalBudget = new Intl.NumberFormat('en-CAD', { style: 'currency', currency: 'CAD' }).format(totalBudget); const footer = displayHeadline(`Total Budget`); // from utils/etLog.js displayResults(`Total Budget: ${totalBudget}`); displayFooter(footer); } catch (err) { if (err) throw err; } }
- utils: Defined etBanner and etLog to design print (ex: font, size, color etc.) page in inquirer.
- Javascript
- Inquirer -- Interactive CLI
- Node.js
- MySQL
- MVC Patterns
- Michael(Eunsoo)Jung
This project is licensed under the MIT License