function addInventory() {
  inquirer
    .prompt([{
        name: "addItem",
        type: "input",
        message: "What is the item number of the product you want to add?",
        filter: Number
      },
      {
        name: "stockNumber",
        type: "input",
        message: "How much stock would you like to add?",
        filter: Number
      }
    ]).then(function (input) {
      var item = input.addItem;
      var quantity = input.stockNumber;
      var queryStr = "SELECT * FROM products WHERE ?";
      connection.query(queryStr,
        [{
            item_ID: item
          },
          {
            stock_quantity: quantity
          },
        ],
        function (err, data) {
          if (err) throw err;
          else {
            var productData = data[0];
            var updateQueryStr = "UPDATE products SET stock_quantity = " + (productData.stock_quantity + quantity) + " WHERE item_id = " + item;
            connection.query(updateQueryStr, function (err, data) {
              if (err) throw err;
              console.log("The stock has been updated.");
              console.log("\n---------------------------------------------------------------------\n");
              connection.end();
            })
          };
        })
    });
}
// Allow users to increase quantity in the database.
Allow users to increase quantity in the database.
Allow users to increase quantity in the database .
function addInventory() {
  inquirer
    .prompt([{
        name: "addItem",
        type: "input",
        message: "What is the item number of the product you want to add?",
        filter: Number
      },
      {
        name: "stockNumber",
        type: "input",
        message: "How much stock would you like to add?",
        filter: Number
      }
    ]).then(function (input) {
      var item = input.addItem;
      var quantity = input.stockNumber;
      var queryStr = "SELECT * FROM products WHERE ?";
      connection.query(queryStr,
        [{
            item_ID: item
          },
          {
            stock_quantity: quantity
          },
        ],
        function (err, data) {
          if (err) throw err;
          else {
            var productData = data[0];
            var updateQueryStr = "UPDATE products SET stock_quantity = " + (productData.stock_quantity + quantity) + " WHERE item_id = " + item;
            connection.query(updateQueryStr, function (err, data) {
              if (err) throw err;
              console.log("The stock has been updated.");
              console.log("\n---------------------------------------------------------------------\n");
              connection.end();
            })
          };
        })
    });
}
function addInventory ( ) { inquirer . prompt ( [ { name : "addItem" , type : "input" , message : "What is the item number of the product you want to add?" , filter : Number } , { name : "stockNumber" , type : "input" , message : "How much stock would you like to add?" , filter : Number } ] ) . then ( function ( input ) { var item = input . addItem ; var quantity = input . stockNumber ; var queryStr = "SELECT * FROM products WHERE ?" ; connection . query ( queryStr , [ { item_ID : item } , { stock_quantity : quantity } , ] , function ( err , data ) { if ( err ) throw err ; else { var productData = data [ 0 ] ; var updateQueryStr = "UPDATE products SET stock_quantity = " + ( productData . stock_quantity + quantity ) + " WHERE item_id = " + item ; connection . query ( updateQueryStr , function ( err , data ) { if ( err ) throw err ; console . log ( "The stock has been updated." ) ; console . log ( "\n---------------------------------------------------------------------\n" ) ; connection . end ( ) ; } ) } ; } ) } ) ; }
Allow users to increase quantity in the database.
Allow users to increase quantity in the database .