Giter VIP home page Giter VIP logo

bamazon's Introduction

#Bamazon

##Welcome to my Bamazon App using Node.js and mySQL!

This is a basic application that manipulates a SQL database with JavaScript code. *User input is processed through inquirer.js.

###How bamazonCustomer.js Works

  1. The bamazonCustomer.js file first connects to the database server port.
  2. The getData() begins the logic of the program by first displaying the items in the database.
  3. It then runs customerPrompt() which captures user input in two inquirer input functions. The first asks to "Select the ID of the item you would like: " and the second "How many would you like?".
  4. Both of these inquires have a validation method so that the user is forced to put a number input.
  5. To save us from possible trouble on the answers returned from inquirer. We sanitize the variables in the .then portion of the inquirer prompt by converting them to integers. Inquirer always returns strings.
  6. A check is conducted with an if statement. We exit the program if the user desires more items then the store can supply. The else statement means the user requested an acceptable amount of items.
  7. We now run aconnect.query function to update the quantity in the database and a second query to display the changes made to the item rows.

###Image

Bamazon Customer in Action

We connect to the database and jump into the **managerPrompt()**function which contains our inquire prompts. The user is limited in their choices so an input would bring an unecessary need to validate user input. Once the user selects what they would like to do we run their command through a switch, each case labeled as one of the choices and lead to their respective functions.

###Functions There are four functions:

  1. getData(), is nearly identical to what it was in the bamazonCustomer.js file. It returns the database data.
  2. viewLow() sends query logic where the item_quantity < 5 and returns them to the user.
  3. addInv() begins a new inquirer prompt to gather what item the user wants and how many they want to add to the quantity. We then select the appropriate row in the database and update it with the new quantity information.
  4. addNewProduct() also begins with an inquirer prompt to gather a few new variables. The name of the item; the department; the item price and the quantity to be stored in the database/warehouse. With this information we conduct another query and insert the new row into the database and call getData once more to display the new database.

####Images

View in Action

Low Quantity in Action

addInv and addNewProduct are having asynchronisity issues and are still works in progress.

However, addNewProduct does work on occasion

bamazon's People

Contributors

maxsmoke avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.