{"id":41781037,"url":"https://github.com/imatic/pgqb","last_synced_at":"2026-01-25T04:02:20.880Z","repository":{"id":22714080,"uuid":"97119922","full_name":"imatic/pgqb","owner":"imatic","description":"Functional PostgreSQL query builder","archived":false,"fork":false,"pushed_at":"2023-09-27T20:38:26.000Z","size":269,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-02T20:38:30.787Z","etag":null,"topics":["nodejs","postgresql","query-builder","sql"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imatic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-13T12:25:02.000Z","updated_at":"2025-02-06T16:24:17.000Z","dependencies_parsed_at":"2025-03-26T20:00:39.293Z","dependency_job_id":null,"html_url":"https://github.com/imatic/pgqb","commit_stats":null,"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"purl":"pkg:github/imatic/pgqb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imatic%2Fpgqb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imatic%2Fpgqb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imatic%2Fpgqb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imatic%2Fpgqb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imatic","download_url":"https://codeload.github.com/imatic/pgqb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imatic%2Fpgqb/sbom","scorecard":{"id":485015,"data":{"date":"2025-08-11","repo":{"name":"github.com/imatic/pgqb","commit":"d7fc32d1c7103c57311ce1fd8d549efbf28345a4"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.7,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/22 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:8: update your workflow using https://app.stepsecurity.io/secureworkflow/imatic/pgqb/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/imatic/pgqb/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/imatic/pgqb/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/imatic/pgqb/ci.yml/master?enable=pin","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 8 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":2,"reason":"8 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-qrpm-p2h7-hrv2","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-76p7-773f-r4q5"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T17:33:14.978Z","repository_id":22714080,"created_at":"2025-08-19T17:33:14.978Z","updated_at":"2025-08-19T17:33:14.978Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28742983,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T02:46:29.005Z","status":"ssl_error","status_checked_at":"2026-01-25T02:44:29.968Z","response_time":113,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nodejs","postgresql","query-builder","sql"],"created_at":"2026-01-25T04:02:19.939Z","updated_at":"2026-01-25T04:02:20.874Z","avatar_url":"https://github.com/imatic.png","language":"TypeScript","readme":"[![Build Status](https://secure.travis-ci.org/imatic/pgqb.png?branch=master)](http://travis-ci.org/imatic/pgqb)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n\n# pgqb\n\nThis library allows you to create dynamic sql queries.\n\nIn case of simple queries, you could just use [template literals][template_literals]:\n```javascript\nconst sql = `\nSELECT *\nFROM \"table\"\n`\n```\n\nIn case you have lots of parameters, you could use [sql-template-strings][sql_template_strings]:\n```javascript\nimport {SQL} from 'sql-template-strings';\n\nconst sqlStatement = `\nINSERT INTO \"table\"\n    (\"col1\", \"col2\")\nVALUES\n    (${val1}, ${val2})\n`;\n```\n\nBut what if you want to create queries dynamically? Splitting queries into several string parts, modifying several parts separately and then concatenating them togheter? There is better way - building queries as javascript data structures, which can be then easilly manipulated, merged, ...\n\nLet's see previous query built using this library:\n```javascript\nimport * as qb from '@imatic/pgqb';\n\nconst sqlMap = qb.merge(\n    qb.insertInto('table'),\n    qb.columns(['col1', 'col2']),\n    qb.values([\n        [\n            qb.val.inlineParam(val1),\n            qb.val.inlineParam(val2),\n        ]\n    ])\n);\n\nconst sqlStatement = qb.toSql(sqlMap);\n```\n\nQuery above automatically escapes identifiers (tables, colums). For now, building the query using this library seems more verbose than using just [sql-template-strings][sql_template_strings]. Imagine you would want to modify the query though. If you wanted to add additional column, you could do it like so:\n```javascript\nimport * as qb from '@imatic/pgqb';\n\nconst sqlMap = qb.merge(\n    qb.insertInto('table'),\n    qb.columns(['col1', 'col2']),\n    qb.values([\n        [\n            qb.val.inlineParam(val1),\n            qb.val.inlineParam(val2),\n        ]\n    ])\n);\n\nconst additionalColumn = qb.merge(\n    qb.columns(['col3']),\n    qb.values([\n        [\n            qb.val.inlineParam(val3),\n        ]\n    ])\n)\n\nconst sqlStatement = qb.toSql(qb.append(sqlMap, additionalColumn));\n```\n\nYour query now inserts 3 columns instead of original 2. You can append other clauses (like `where`) too.\n\n## Inspiraton\n\nThis library was inspired by [honeysql][honeysql].\n\n[template_literals]: https://developer.mozilla.org/cs/docs/Web/JavaScript/Reference/Template_literals\n[sql_template_strings]: https://www.npmjs.com/package/sql-template-strings\n[honeysql]: https://github.com/jkk/honeysql\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimatic%2Fpgqb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimatic%2Fpgqb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimatic%2Fpgqb/lists"}