var mysql = require('mysql');
const SQL = require('./functions/SQL.js')
var request = "SELECT * FROM users"
console.log(
SQL.GetFromSQL(pool, request) //возвращает undefined
)
module.exports = { GetFromSQL }
function GetFromSQL (pool, request) {
pool.getConnection(function (err, connection) {
if (err) throw err;
connection.query(request, function (error, results, fields) {
connection.release();
if (error) throw error;
return results
});
});
}
module.exports = { GetFromSQL }
function GetFromSQL (pool, request, callback) {
pool.getConnection(function (err, connection) {
if (err) throw err;
connection.query(request, function (error, results, fields) {
connection.release();
if (error) throw error;
callback(results)
});
});
}
SQL.GetFromSQL(pool, request, function(results) {
// lol kek
})