A Node.js module that loads SQL files from disk and exports them as parameterized query functions for use with the `pg` (node-postgres) library. v1.0.0, stable but no recent updates. Key differentiator: auto-generates named query functions from .sql files, reducing boilerplate when embedding SQL in Node.js applications. Not actively maintained; ESM imported with .js extension.
npm install pg-require-sqlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to load SQL files from a directory, bind them to a pg Pool, and execute a named query.
Ensure SQL filenames are lowercase with hyphens or underscores; avoid special characters.
Call the function, e.g., `queries.getUser(id)`, not `client.query(...)`.
Use `path.resolve()` to build absolute path.
Use `path.resolve('./sql')` for cross-platform compatibility.Run `npm install pg-require-sql` and ensure package.json includes 'type': 'module' or use .mjs extension.
Use `import loadQueries from 'pg-require-sql'` and set 'type': 'module' in package.json.
Ensure you pass a `pg.Pool` instance (e.g., `new pg.Pool(...)`) as the second argument.