Disclaimer: I am really tired and therefore my thinking ability isn't the greatest right now.
I want to write a code where I can choose that the program connects to a database or uses files for storage, etc.
I wish to make it so that my main program calls a function let's say DataHandler.read(users) and the rest of it is dealt with. (Another file which is imported deals with it.)
let dataHandler = {};
const databaseJS = require('./database');
dataHandler.connection = databaseJS.connect(database);
dataHandler.read = async function(data) {return await databaseJS.read(dataHandler.connection, data);};
// 1
let output = await dataHandler.read("SHOW DATABASES");
console.log(output);
// 2
dataHandler.read("SHOW DATABASES").then(output => {console.log(output);});
The 1.st thing is what I want, I would like to avoid using .then
But only the second part works. If I remove the await from the first it gives back a promise, I dunno where else to put my await.