title: Node error " Cannot read property 'insertId' of undefined"
body: <p>I am new in node and I download an signup example it is show an error:</p>
  
  <blockquote>
    <p>" Cannot read property 'insertId' of undefined"</p>
  </blockquote>
  
  <pre><code>passport.serializeUser(function(user, done) {
      done(null, user.id);
  });
  
  
  passport.deserializeUser(function(id, done) {
      connection.query("SELECT * FROM singup WHERE id = ? ",[id], function(err, rows){
          done(err, rows[0]);
      });
  });
  
  
  passport.use(
      'local-signup',
      new LocalStrategy({
  
          fullnameField : 'fullname',
          usernameField : 'username',
          passwordField : 'password',
          passReqToCallback : true 
      },
      function(req,fullname, username, password, done) {
  
          connection.query("SELECT * FROM singup WHERE username = ?",[username], function(err, rows) {
              if (err)
                  return done(err);
              if (rows.length) {
                  return done(null, false, req.flash('signupMessage', 'That username is already taken.'));
              } 
              else {
  
                  var newUserMysql = {
                      id:"2",
                      fullname: fullname,
                      username: username,
                      password: bcrypt.hashSync(password, null, null)  
                  };
  
                  var insertQuery = "INSERT INTO singup (fullname, username, password ) values (?,?,?)";
  
                  connection.query(insertQuery,[newUserMysql.fullname, newUserMysql.username, newUserMysql.password],function(err, rows) {
  
                      newUserMysql.id = rows.insertId;
                      return done(null, newUserMysql);
                  });
              }
          });
      })
  );
  </code></pre>
  
  <p><br></p>
  
  <pre><code> //TypeError: Cannot read property 'insertId' of undefined
      at Query.&lt;anonymous&gt; (E:\testing\nodejs\config\passport.js:71:48)
      at Query.&lt;anonymous&gt; (E:\testing\nodejs\node_modules\mysql\lib\Connection.js:502:10)
      at Query._callback (E:\testing\nodejs\node_modules\mysql\lib\Connection.js:468:16)
      at Query.Sequence.end (E:\testing\nodejs\node_modules\mysql\lib\protocol\sequences\Sequence.js:83:24)
      at Query.ErrorPacket (E:\testing\nodejs\node_modules\mysql\lib\protocol\sequences\Query.js:90:8)
      at Protocol._parsePacket (E:\testing\nodejs\node_modules\mysql\lib\protocol\Protocol.js:278:23)
      at Parser.write (E:\testing\nodejs\node_modules\mysql\lib\protocol\Parser.js:76:12)
      at Protocol.write (E:\testing\nodejs\node_modules\mysql\lib\protocol\Protocol.js:38:16)
      at Socket.&lt;anonymous&gt; (E:\testing\nodejs\node_modules\mysql\lib\Connection.js:91:28)
      at Socket.&lt;anonymous&gt; (E:\testing\nodejs\node_modules\mysql\lib\Connection.js:502:10)
  </code></pre>