Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function sql(file) {
var fullPath = path.join(__dirname, file); // generating full path;
var qf = new QueryFile(fullPath, { minify: true });
if (qf.error) {
throw qf.error;
}
return qf;
}
try {
scripts = Fs.readdirSync(dir).filter((file) => Path.extname(file) === '.sql');
}
catch (e) {
// let's not bother trying to get coverage for fs errors
// $lab:coverage:off$
if (e.code === 'ENOENT') {
return queries;
}
throw e;
// $lab:coverage:on$
}
for (const script of scripts) {
queries[Path.basename(script, '.sql')] = new PG.QueryFile(Path.join(dir, script), { minify: true, debug: process.env.NODE_ENV !== 'production', noWarnings: true });
}
return queries;
};
loadSQLFile(filePath, sqlDirectory = this.sqlDirectory) {
const fullPath = path.join(sqlDirectory, filePath); // Generating full path;
if (_private.queryFiles[fullPath]) {
return _private.queryFiles[fullPath];
}
const options = {
minify: true, // Minifies the SQL
};
const qf = new QueryFile(fullPath, options);
if (qf.error) {
this.logger.error({ err: qf.error }, 'SQL query file error'); // Something is wrong with our query file
throw qf.error; // throw pg-promisse QueryFileError error
}
_private.queryFiles[fullPath] = qf;
return qf;
}
export const loadQueryFile = (directory, file) => {
const fullPath = path.join(directory, file);
const options = {
minify: true,
params: {
schema: "public",
},
};
const query = new QueryFile(fullPath, options);
if (query.error) {
logger.error(query.error.toString());
}
return query;
};
var sql = function (file) {
return new QueryFile(__dirname + '/' + file, {minify: true});
};
const sql = file => QueryFile(path.join(__dirname, file), { minify: true });