I am writing a piece of code to build a schema from DB and based on other examples on SE, I came up with this way to pass down table name all the way to the code where I will process the table fields (I need access to the table name at that time). The schema is coming from MySQL using jugglingdb-mysql.
Is this the most 'elegant' I can do (I would prefer not to have closures in the code as they are written now)?
schema.client.query('SHOW TABLES', function(err, data) {
    if (err) throw err;
    data.forEach(function(table) {
        // closure to pass down table name
        (function(_table) {
            schema.client.query('SHOW columns FROM ' + _table, function(err, rows) {
                if (err) throw err;
                // closure to pass down table name
                (function(_table) {
                    rows.forEach(function(row){
                        // Go wild processing fields
                    })
                })(_table);
            });
        })(table['Tables_in_db'])
    });
});
 
     
    