How to use the pg-promise.QueryFile function in pg-promise

To help you get started, we’ve selected a few pg-promise examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github parse-community / parse-server / src / Adapters / Storage / Postgres / sql / index.js View on Github external
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;
}
github nlf / muckraker / lib / index.js View on Github external
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;
};
github LiskHQ / lisk-sdk / framework / src / components / storage / adapters / pgp_adapter.js View on Github external
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;
	}
github ArkEcosystem / core / packages / core-snapshots / src / db / utils / index.ts View on Github external
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;
};
github Groovy-Narwhal / GitAchieve / server / db / sql / sql.js View on Github external
var sql = function (file) {
  return new QueryFile(__dirname + '/' + file, {minify: true});
};
github chaynHQ / little-window / src / database / db_build.js View on Github external
const sql = file => QueryFile(path.join(__dirname, file), { minify: true });