title: Convert NodeJs MySQL result to accessible JSON Object
body: <p>I want to get some data from my database. Example:</p>
  
  <pre><code>  getCarIds: function (callback) {
      db.query("SELECT Id FROM Cars;",
        function (err, result) {
          if (err) throw err;
  
          result = JSON.stringify(result);
  
          var cars = [];
  
          for (var i = 0; i &lt; result.length; i++) {
            var currentCar = result[i];
            var carId = currentCar.id;
            cars.push(carId);
          }
  
          callback(cars);
        });
    }
  </code></pre>
  
  <p>I want to store all the ids into an array. Like</p>
  
  <pre><code>cars = [1,2,3,4,5];
  </code></pre>
  
  <p>The result returns this</p>
  
  <pre><code>[ RowDataPacket { Id: '1' },
    RowDataPacket { Id: '2' },
    RowDataPacket { Id: '3' } ]
  </code></pre>
  
  <p>So I try to convert it by writing</p>
  
  <pre><code>result = JSON.stringify(result);
  </code></pre>
  
  <p>this returns me</p>
  
  <pre><code>[{"Id":"1"},{"Id":"2"},{"Id":"3"}]
  </code></pre>
  
  <p>when I want to access this object by writing</p>
  
  <p><code>result[0]</code></p>
  
  <p>I get </p>
  
  <p><code>[</code></p>
  
  <p>so obviously </p>
  
  <pre><code>result[0].id
  </code></pre>
  
  <p>will return</p>
  
  <pre><code>undefined
  </code></pre>
  
  <p>How can I get all the ids from the object?</p>