Employee Tracker is a command-line application to manage a company's employee database. With this application, you will be able to view and update 3 SQL tables (department, role, and employee). The purpose of this application is to have a Content Management System so that non-developers can easily view and interact with information stored in databases. The application uses Node.js, Inquirer, and MySQL.
To begin the application, use the following in command line:
node server.js
- Install node package manager (npm)
npm install -g npm
- Install dependencies inquirer, console.table, and mysql2
npm install
Screenshot of Initial Prompt
Screenshot of View Employees table
Screenshot of Add Department prompt
Screenshot of Add Role prompt
Screenshot of Add Employee prompt
Screenshot of Update Employee prompt
This code snippet shows how you can use SQL and npm mysql2 to create a function to view the departments table
-
const sql uses Structured Query Language SELECT statement to display columns with an alias FROM the department table
-
".query" is a built-in method in npm mysql2 to execute a query in the mysql database
-
"console.table()" method displays tabular data as a table
function viewDepartments() {
const sql =
"SELECT department.id AS id, department.name AS department FROM department;";
db.query(sql, (err, data) => {
if (err) {
console.log(err);
}
console.table(data);
initPrompt();
});
}
-
How to use npm mysql2 to generate MySQL queries
-
How to use promises and switch statements
-
How to use SQL statements (SELECT, INSERT, DELETE, UPDATE, JOIN)
-
How to use MySQL Workbench as a MySQL graphical user interface
1. Elliot Park