How to get value for a particular row and column using node.js

I am pretty new to node.js

For my application, I am currently fetching a set of rows using the code below and iterate over each row for value of a particular column...

    query = 'select ' + colName + 
            ' from ' + rows[0].tablename + 
            ' where ' + 
            'dictionaryid=' + rows[0].dictionaryid + 
            ' and id between ' + lower + ' and ' + upper;
    connection.query(query, function(err, rows1, fields) {
      if (err) {
        console.log(err);
        throw err;
      }

      var contents = [];
      rows1.forEach(function(elem) {
        for (var key in elem) {
            if (key == colName) {
                           contents.push(elem[key]);         
                }
         }
      });

So, in the code above, I fetch a set of rows in rows1 and iterate over all of them using a forEach.

What I want to do it to access something like rows1[i][key] i.e like 3rd column of 4th row.

How do I do it.

Any help is appreciated.

Thanks.

You could use underscore toArray to do something like this:

  var _ = require('underscore');

  var contents = [];
  rows1.forEach(function(elem) {
    contents.push(_.toArray(elem));
  });

  var someValue = contents[3][2]; //3rd column of 4th row.