Skip to content

Build a solution for managing a company's employees using node, inquirer, and MySQL

Notifications You must be signed in to change notification settings

EunsooJung/Employee-Tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Employee-Tracker

Build a CLI application to manage company's employees using node, inquirer, and MySQL.

Getting Started

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)

Preview

Employee-Tracker

Usage

Basic Usage

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

Guidelines:

  • Proceeds as follows:

To use this applicaion, Clone the applicaion to your local git repository or directory:

To start:

  • Open your terminal then "node index.js"

Code Snippet

  • Project structure

    [Employee Tracker]

  • Source Code Check point

    1. ORM - EmpTrackerDB.js: Connect to MySQL Database, reset database and defined db schema.
    2. 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']);
          }
        });
      });
    }
    1. View layer example: index.js using the inquirer
    • import controllers into the index.js
      switch (answer.action.toLowerCase()) {
        case 'view all employees':
          await displayAllEmployees();
    1. 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;
      }
    }
    1. utils: Defined etBanner and etLog to design print (ex: font, size, color etc.) page in inquirer.

Built With

Authors

  • Michael(Eunsoo)Jung

License

This project is licensed under the MIT License

About

Build a solution for managing a company's employees using node, inquirer, and MySQL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published