I do not know if I am asking the right question in the right group or what, but I can use some help here. I am trying to build a node.js application having the node oracle module. I want to read the raw sql files on my server side and use them in my connection.execute(select.toString(), [], function(err, results)
function. So to test it I create a var and did select * from inventory
and it works as anticipated. So now I figure why retype just read my sql files and if I want to make changes I just change the sql file. Below is my code, how the heck do I get these in my select var. I have been told to use readFileSync
but I read you should not use that on the server side. And yes I am new, just about four days with node.
foo.js
var fs = require('fs');
function sql_file(sql_file, cb) {
console.log('about to read file');
var fileName = "./SQLs/" + sql_file;
fs.readFile(fileName, function(err, buffer) {
console.log('the file has been read');
if (err) return cb(err);
return cb(null, buffer.toString());
});
console.log('call to read file made (but not finished)');
}
sql_file('inventory.sql', function(err, contents) {
console.log(contents.toString());
});
module.exports.sql_file = sql_file;