Hello I tried using SQL connection files with other files but for some reason it always gives me error or doesn't show anything. Can somebody please help me where I am going wrong or is it allowed in BAS?
Here's the code:
config
module.exports = async function () {
const mysql = require('mysql2');
// create the connection to database
const connection = mysql.createConnection({
host: 'localhost',
user: 'user',
database: 'user'
});
}
Current:
await require("../mysqlconfig")();
module.exports = async function () {
await (new Promise((resolve, reject) => {
connection.query(
'SELECT * FROM `table` WHERE 1 LIMIT 1',
function (err, results, fields) {
if (err) {
reject(err)
return
}
if(results.length>0){
console.log(results)
console.log(err)
}
else
console.log("Not found")
console.log(err)
resolve()
}
);
}))
}