text: 
  /*
   * GET users listing.
   */
  
  exports.list = function(req, res){
  
    req.getConnection(function(err,connection){
         
          var query = connection.query('SELECT * FROM mahasiswa',function(err,rows)
          {
              
              if(err)
                  console.log("Error Selecting : %s ",err );
       
              res.render('mahasiswa',{page_title:"mahasiswa - Node.js",data:rows});
                  
             
           });
           
           //console.log(query.sql);
      });
    
  };
  
  exports.add = function(req, res){
    res.render('add_mahasiswa',{page_title:"Add mahasiswa - Node.js"});
  };
  
  exports.edit = function(req, res){
      
      var id = req.params.id;
      
      req.getConnection(function(err,connection){
         
          var query = connection.query('SELECT * FROM mahasiswa WHERE id = ?',[id],function(err,rows)
          {
              
              if(err)
                  console.log("Error Selecting : %s ",err );
       
              res.render('edit_mahasiswa',{page_title:"Edit mahasiswa - Node.js",data:rows});
                  
             
           });
           
           //console.log(query.sql);
      }); 
  };
  
  /*Save the mahasiswa*/
  exports.save = function(req,res){
      
      var input = JSON.parse(JSON.stringify(req.body));
      
      req.getConnection(function (err, connection) {
          
          var data = {
              
              name    : input.name,
              address : input.address,
              email   : input.email,
              phone   : input.phone 
          
          };
          
          var query = connection.query("INSERT INTO mahasiswa set ? ",data, function(err, rows)
          {
    
            if (err)
                console.log("Error inserting : %s ",err );
           
            res.redirect('/mahasiswa');
            
          });
          
         // console.log(query.sql); get raw query
      
      });
  };
  
  exports.save_edit = function(req,res){
      
      var input = JSON.parse(JSON.stringify(req.body));
      var id = req.params.id;
      
      req.getConnection(function (err, connection) {
          
          var data = {
              
              name    : input.name,
              address : input.address,
              email   : input.email,
              phone   : input.phone 
          
          };
          
          connection.query("UPDATE mahasiswa set ? WHERE id = ? ",[data,id], function(err, rows)
          {
    
            if (err)
                console.log("Error Updating : %s ",err );
           
            res.redirect('/mahasiswa');
            
          });
      
      });
  };
  
  
  exports.delete_mahasiswa = function(req,res){
            
       var id = req.params.id;
      
       req.getConnection(function (err, connection) {
          
          connection.query("DELETE FROM mahasiswa  WHERE id = ? ",[id], function(err, rows)
          {
              
               if(err)
                   console.log("Error deleting : %s ",err );
              
               res.redirect('/mahasiswa');
               
          });
          
       });
  };
  
  
  