January 2020
Intermediate to advanced
530 pages
11h 11m
English
After the transaction is successfully submitted to the blockchain network, the customer's balance is updated in the customers table. The updation process is carried out by the updateBal() method.
The method accepts the transaction details through the trans object as an input parameter, as shown in the following code snippet:
var updateBal = function(trans,res) {
We fetch the customer balance from the customers table, like this:
client.query('SELECT balance from customers where account = $1', [trans.account], (error, results)=> {
On the response from the pg client, we check for any error responses. In the case of no errors, we deduct the transaction amount from the customer's balance, and run ...
Read now
Unlock full access