controllers/api.js
function insertIntoDB() {
                    lastQry = connection.query('INSERT INTO ?? SET ?', [req.params.table , insertJson] , function (err, rows) {
                        if (err) {
                            console.error(err);
                            res.statusCode = 500;
                            res.send({
                                result: 'error',
                                err: err.code
                            });
                        } else {
                            sendSuccessAnswer(req.params.table , res, rows.insertId);
                        }

                    });
                }
function insertIntoDB() {
                    lastQry = connection.query('INSERT INTO ?? SET ?', [req.params.table , insertJson] , function (err, rows) {
                        if (err) {
                            console.error(err);
                            res.statusCode = 500;
                            res.send({
                                result: 'error',
                                err: err.code
                            });
                        } else {
                            sendSuccessAnswer(req.params.table , res, rows.insertId);
                        }

                    });
                }
function insertIntoDB ( ) { lastQry = connection . query ( 'INSERT INTO ?? SET ?' , [ req . params . table , insertJson ] , function ( err , rows ) { if ( err ) { console . error ( err ) ; res . statusCode = 500 ; res . send ( { result : 'error' , err : err . code } ) ; } else { sendSuccessAnswer ( req . params . table , res , rows . insertId ) ; } } ) ; }
start the async "for" loop 
When the loop is finished write everything in the database
start the async for loop When the loop is finished write everything in the database