Amazon type application for further node and mySQL knowledge. Customer file has a set list of items and monitors available stock. Stock will deplete based upon user input of desired quantity. Manager file allows the user to audit product information.
Run 'node bamazonCustomer' in terminal to begin. Available product will be displayed in a table for the user. User will then be prompted to input ID number of desired product:
;
After the user enters desired ID, the user will be asked the quantity they desire to purchase:
If the user does not supply an input that is a non-zero integer then they will be asked to enter a non-zero number:
Once these questions are successfully answered, the stock data column will be updated to reflect new available stock.
Original mySQL data:
Updated Data Row:
The user is then prompted that their order was successfully placed and given the total of their order:
If there is not enough stock to supply desired demand, the user will be updated in the console:
Run 'node bamazonManager' in the terminal to begin. User will be prompted with a list of things to do with product:
After each task the user will be prompted with a question asking if they would like to do anything else:
If the user answers yes then they will be shown the starting list. If the user answers no then the connection will end.
Manager's options:
Option 1: View available products. If the user chooses this option then a table will display all of the information about all available products.
Option 2: View products with low inventory. If the user chooses this option, a table will display all the items that have a stock quantity lower than 5.
Option 3: Add inventory to product. This options allows the user to add inventory to an exsisting product. It will first display the products available and ask the user to input a product ID (the user will be limited to only integars that are equal to a valid product ID).
After choosing a valid ID number, the user will be asked how much stock they would like to add.
Once the stock is added, the user is prompted that the stock has been added and shown the updated items table.
Option 4: Add a product. As stated in the title of this option, the function here allows the user to add a new product to the table of available products. Once this option is selected, the user will be prompted to provide details for this new item. Details such as; product name, product department, product price and how much product is in stock.
Once these questions are answered, the terminal will display a table with the users input and ask them to double check that the information is correct.
If the user answers no then they will be asked the questions again. Else they will be alerted that the product has been added to the database.
Dependencies: mysql, inquirer, console.table
Terminal command for downloading dependencies
npm i mysql
npm i inquirer
npm i console.table
Initialize Dependencies
const mysql = require("mysql");
const inquirer = require("inquirer");
require("console.table");
Note: console.table is used just like console.log, e.g. console.table('table to be logged in console');
- Corey Mitchell - (https://github.com/corey-mitchell)