How to use the pg-promise/lib/patterns.namedParameters 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 brockpettyjohn / personal-project / node_modules / massive / lib / loader / scripts.js View on Github external
}).then(files => files.map(f => {
  const queryFile = new pgp.QueryFile(f, {minify: true});
  const sql = queryFile.formatDBType();
  const valuesMatch = sql.match(patterns.multipleValues);
  const namesMatch = sql.match(patterns.namedParameters);

  return {
    schema: path.relative(config.scripts, path.dirname(f)).replace(path.sep, '.'),
    name: path.basename(f, '.sql'),
    sql: queryFile,
    paramCount: (valuesMatch && valuesMatch.length || 0) + (namesMatch && namesMatch.length || 0)
  };
}));