I want to create functions that fetches data from database for example executeQuery(sql)
. But I don't want any promise returned from this function or want to pass any callback function. I just want to return the result of the query.
For example:
var rows = executeQuery('SELECT * FROM table');
console.log('database query completed:', rows);
I know this is not how javascript works. I've also gone through number of stackoverflow questions that also wanted this thing. But everyone says that there's no way to do that.
Now here's my question if that's not possible then how functions like fs.readFileSync()
work. These functions neither require any callbacks nor they return any promise. They just do what they are defined to do.