function qtyMath(qty, id) {
    var tst = connection.query(
        "SELECT * FROM products WHERE ?", [{
            item_id: id
        }],
        function (err, res) {
            let qtyLeft = (res[0].stock_quantity - qty);
            let total = (res[0].price * qty);
            if (qtyLeft < 0) {
                console.log("***quantity exceeds stock available, please try again!***");
                start();
            } else {
                updateTable(qtyLeft, id, total);
            }
        });
    }
//more than quantity available it start back(recursion)
more than quantity available it start back(recursion)
more than quantity available it start back ( recursion )
function qtyMath(qty, id) {
    var tst = connection.query(
        "SELECT * FROM products WHERE ?", [{
            item_id: id
        }],
        function (err, res) {
            let qtyLeft = (res[0].stock_quantity - qty);
            let total = (res[0].price * qty);
            if (qtyLeft < 0) {
                console.log("***quantity exceeds stock available, please try again!***");
                start();
            } else {
                updateTable(qtyLeft, id, total);
            }
        });
    }
function qtyMath ( qty , id ) { var tst = connection . query ( "SELECT * FROM products WHERE ?" , [ { item_id : id } ] , function ( err , res ) { let qtyLeft = ( res [ 0 ] . stock_quantity - qty ) ; let total = ( res [ 0 ] . price * qty ) ; if ( qtyLeft < 0 ) { console . log ( "***quantity exceeds stock available, please try again!***" ) ; start ( ) ; } else { updateTable ( qtyLeft , id , total ) ; } } ) ; }
more than quantity available it start back(recursion)
more than quantity available it start back ( recursion )