{"id":20375091,"url":"https://github.com/hebertcisco/pgnode","last_synced_at":"2025-07-01T10:03:02.095Z","repository":{"id":42431136,"uuid":"376993348","full_name":"hebertcisco/pgnode","owner":"hebertcisco","description":"PostgresSQL client to Nodejs servers","archived":false,"fork":false,"pushed_at":"2024-07-24T00:50:41.000Z","size":1128,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-05-15T19:42:38.057Z","etag":null,"topics":["database","javascript","nodejs","pgsql-connection-pooling","postgres","postgresql","postgressql","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/pgnode","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/hebertcisco.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":"hebertfbarros","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2021-06-15T00:42:40.000Z","updated_at":"2024-07-24T00:50:43.000Z","dependencies_parsed_at":"2023-12-13T22:11:36.601Z","dependency_job_id":"e392cb70-4b72-4898-8fe4-72f0c0ed685c","html_url":"https://github.com/hebertcisco/pgnode","commit_stats":{"total_commits":129,"total_committers":5,"mean_commits":25.8,"dds":"0.45736434108527135","last_synced_commit":"ae065935d650cdcad9479ea509b207e445b2ef5c"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":"hebertcisco/ts-npm-package-boilerplate","purl":"pkg:github/hebertcisco/pgnode","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hebertcisco%2Fpgnode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hebertcisco%2Fpgnode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hebertcisco%2Fpgnode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hebertcisco%2Fpgnode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hebertcisco","download_url":"https://codeload.github.com/hebertcisco/pgnode/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hebertcisco%2Fpgnode/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260238414,"owners_count":22979561,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["database","javascript","nodejs","pgsql-connection-pooling","postgres","postgresql","postgressql","typescript"],"created_at":"2024-11-15T01:28:45.523Z","updated_at":"2025-07-01T10:03:02.046Z","avatar_url":"https://github.com/hebertcisco.png","language":"TypeScript","funding_links":["https://patreon.com/hebertfbarros","https://www.buymeacoffee.com/hebertcisco"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n \u003cimg width=\"100px\" src=\"https://raw.githubusercontent.com/hebertcisco/pgnode/main/.github/images/favicon512x512-postgresql.png\" align=\"center\" alt=\":package: postgresql\" /\u003e\n \u003ch2 align=\"center\"\u003e:package: pgnode\u003c/h2\u003e\n \u003cp align=\"center\"\u003ePostgresSQL client to Nodejs servers\u003c/p\u003e\n\n  \u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/hebertcisco/pgnode/issues\"\u003e\n      \u003cimg alt=\"Issues\" src=\"https://img.shields.io/github/issues/hebertcisco/pgnode?style=flat\u0026color=336791\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/hebertcisco/pgnode/pulls\"\u003e\n      \u003cimg alt=\"GitHub pull requests\" src=\"https://img.shields.io/github/issues-pr/hebertcisco/pgnode?style=flat\u0026color=336791\" /\u003e\n    \u003c/a\u003e\n     \u003ca href=\"https://github.com/hebertcisco/pgnode\"\u003e\n      \u003cimg alt=\"GitHub Downloads\" src=\"https://img.shields.io/npm/dw/pgnode?style=flat\u0026color=336791\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/hebertcisco/pgnode\"\u003e\n      \u003cimg alt=\"GitHub Total Downloads\" src=\"https://img.shields.io/npm/dt/pgnode?color=336791\u0026label=Total%20downloads\" /\u003e\n    \u003c/a\u003e\n \u003cbr /\u003e\n    \u003cbr /\u003e\n  \u003ca href=\"https://github.com/hebertcisco/pgnode\"\u003e\n      \u003cimg alt=\"GitHub release\" src=\"https://img.shields.io/github/release/hebertcisco/pgnode.svg?style=flat\u0026color=336791\" /\u003e\n    \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/pg\"\u003e\n      \u003cimg alt=\"dependency pg\" src=\"https://img.shields.io/github/package-json/dependency-version/hebertcisco/pgnode/pg?style=flat\u0026color=336791\" /\u003e\n    \u003c/a\u003e\n \u003cbr /\u003e\n    \u003cbr /\u003e\n    \u003cbr /\u003e\n  \u003ca href=\"https://github.com/hebertcisco/musiko-app/issues/new/choose\"\u003eReport Bug\u003c/a\u003e\n  \u003ca href=\"https://github.com/hebertcisco/musiko-app/issues/new/choose\"\u003eRequest Feature\u003c/a\u003e\n  \u003c/p\u003e\n \u003ch3 align=\"center\"\u003eSystems on which it has been tested.\u003c/h3\u003e\n \u003cp align=\"center\"\u003e\n    \u003ca href=\"https://ubuntu.com/download\"\u003e\n      \u003cimg alt=\"Ubuntu\" src=\"https://img.shields.io/badge/Ubuntu-E95420?style=for-the-badge\u0026logo=ubuntu\u0026logoColor=white\u0026style=flat\" /\u003e\n    \u003c/a\u003e\n  \u003ca href=\"https://alpinelinux.org/\"\u003e\n      \u003cimg alt=\"Alpine_Linux\" src=\"https://img.shields.io/badge/Alpine_Linux-0D597F?style=for-the-badge\u0026logo=alpine-linux\u0026logoColor=white\u0026style=flat\" /\u003e\n    \u003c/a\u003e\n \u003cbr /\u003e\n    \u003cbr /\u003e\n  \u003ca href=\"https://www.debian.org/index.pt.html\"\u003e\n      \u003cimg alt=\"Debian\" src=\"https://img.shields.io/badge/Debian-A81D33?style=for-the-badge\u0026logo=debian\u0026logoColor=white\u0026style=flat\" /\u003e\n    \u003c/a\u003e\n  \u003ca href=\"https://www.centos.org/\"\u003e\n      \u003cimg alt=\"CentOS\" src=\"https://img.shields.io/badge/Cent%20OS-262577?style=for-the-badge\u0026logo=CentOS\u0026logoColor=white\u0026style=flat\" /\u003e\n    \u003c/a\u003e\n \u003cbr /\u003e\n    \u003cbr /\u003e\n  \u003ca href=\"https://www.microsoft.com/pt-br/windows/\"\u003e\n      \u003cimg alt=\"Windows\" src=\"https://img.shields.io/badge/Windows-0078D6?style=for-the-badge\u0026logo=windows\u0026logoColor=white\u0026style=flat\" /\u003e\n    \u003c/a\u003e\n \u003ca href=\"https://www.apple.com/br/macos/\"\u003e\n      \u003cimg alt=\"Macos\" src=\"https://img.shields.io/badge/mac%20os-000000?style=for-the-badge\u0026logo=apple\u0026logoColor=white\u0026style=flat\" /\u003e\n    \u003c/a\u003e\n  \u003c/p\u003e\n\u003cp align=\"center\"\u003eDid you like the project? Please, considerate \u003ca href=\"https://www.buymeacoffee.com/hebertcisco\"\u003ea donation\u003c/a\u003e to help improve!\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\u003cstrong\u003ePostgresSQL client to Nodejs servers\u003c/strong\u003e✨\u003c/p\u003e\n\n\u003cp align=\"center\"\u003eConnect your database easily using the pgnode package\u003c/p\u003e\n\n# Getting started\n\n## Installation\n\nTo install the module in your project just run the command below:\n\n```bash\nnpm i pgnode\n```\n\nor\n\n```bash\nyarn add pgnode\n```\n\nNow in your project just import the module like this:\n\n```js\nconst pg = require(\"pgnode\");\n```\n\nOr you can use import:\n\n```js\nimport pg from \"pgnode\";\n```\n\n## Client connection\n\nThis is the simplest possible way to connect, query, and disconnect with async/await:\n\n```ts\nimport pg, { Client, Pool } from \"pgnode\";\n\nconst config = {\n  user: process.env.POSTGRES_USER,\n  host: process.env.POSTGRES_HOST,\n  database: process.env.POSTGRES_DATABASE,\n  password: process.env.POSTGRES_PASSWORD,\n  port: Number(process.env.POSTGRES_PORT),\n};\n\nconst client = new pg.Client({ ...config });\n\nfunction query(sql, params) {\n  return client\n    .connect()\n    .then(() =\u003e client.query(sql, params))\n    .then((res) =\u003e {\n      client.end();\n      return res;\n    });\n}\n```\n\n# Transactions (tx)\n\n## Usage\n\n```Typescript\nimport {tx, Client, Pool} from 'pgnode';\n\nconst client = new Client({\n  user: process.env.POSTGRES_USER,\n  host: process.env.POSTGRES_HOST,\n  database: process.env.POSTGRES_DATABASE,\n  password: process.env.POSTGRES_PASSWORD,\n  port: Number(process.env.POSTGRES_PORT)\n});\n\nconst pool = new Pool({...client});\n\nexport async function createTable(){\n  return await tx(pool, async (db) =\u003e {\n    await db.query(`\n      CREATE TABLE IF NOT EXISTS test\n      (\n        id   SERIAL PRIMARY KEY,\n        name TEXT NOT NULL\n      );`);\n  });\n}\n\n// or use a generator function to create the transactions\n\nexport function* createTableGenerator(){\n  yield tx(pool, async (db) =\u003e {\n    await db.query(`\n      CREATE TABLE IF NOT EXISTS test\n      (\n        id   SERIAL PRIMARY KEY,\n        name TEXT NOT NULL\n      );`);\n  });\n  // create another transaction\n  yield tx(pool, async (db) =\u003e {\n    await db.query(`\n      INSERT INTO test (name) VALUES ('test');`);\n  });\n}\n```\n\n# Features\n\n- **Pure JavaScript** client and native libpq bindings share the same API\n- Support all `tls.connect` options being passed to the client/pool constructor under the `ssl` option.\n- Connection pooling\n- **Extensible JS** ↔ PostgreSQL data-type coercion\n- Supported PostgreSQL features\n  - Parameterized queries\n  - Named statements with query plan caching\n  - Async notifications with `LISTEN/NOTIFY`\n  - Bulk import \u0026 export with `COPY TO/COPY FROM`\n  - Change default database name\n  - make pg.Pool an es6 class\n  - `pg.Client` and `pg.Pool` are ES6 classes\n  - Support for `pg.Client.prototype.query` and `pg.Pool.prototype.query`\n  - Support generator functions\n  - Support for Nodejs `^v16x`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhebertcisco%2Fpgnode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhebertcisco%2Fpgnode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhebertcisco%2Fpgnode/lists"}