Friday, 2 June 2017

How to pass multiple parameters from route to view in express node.js

I have a problem, actually what I want to achieve is in the first query I want to fetch all the tables from a database and then for each table, I want to get its respective columns. My code in route is like this

var insert_sql = "SHOW TABLES FROM `X`";
req.getConnection(function(err,connection){
   if (err) throw err;
   var query = connection.query(insert_sql,function(err, result){
        console.log(result);
        if(err)
        {
            console.log("Error Insert:"+err );
        }else{
            console.log("query sucess:");
        }       
    });
                console.log(insert_sql.sql);
            });

But I'm unable to do it in a loop for all the tables say, X,Y,Z for each table I have to fetch columns and send all this data to view. Can anyone help me?



via sunshine

No comments:

Post a Comment