I want to pass a result from mysql query to the level above...
I have this module: mySQLconnect.js:
var connection = require('mysql').createConnection({
host : 'localhost',
user : 'admin',
password : ''
});
exports.querySelect = querySelect;
function querySelect(query){
var result = connection.query(query, function(err, rows){
return (rows[0]);
});
return result;
}
and when I call this function from outside, let's say from app.js:
var DBconnector = require('mySQLconnect');
var result = DBconnector.querySelectUser("SELECT * FROM TB_USERS");
but the result I get is something else - it's an object from mysql.js module that's been received from:
connection.query(query, function(err, rows)
it has: _resultSet =null, and unreachable _results =[Array]
so it's no good...
I checked in node-mysql website, but didn't find what's connection.query returns.
any ideas how can I pass the result?