{"id":15187424,"url":"https://github.com/lupennat/lupdo-postgres","last_synced_at":"2026-01-21T03:02:19.812Z","repository":{"id":65150717,"uuid":"582959552","full_name":"Lupennat/lupdo-postgres","owner":"Lupennat","description":"Lupdo Driver For PostgreSQL","archived":false,"fork":false,"pushed_at":"2024-09-27T16:08:42.000Z","size":361,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-04T22:50:35.512Z","etag":null,"topics":["abstraction-layer","database","lupdo","nodejs","pdo","pg","pgsql","postgres","postgres11","postgres12","postgres13","postgres14","postgres15","postgresql","transactions"],"latest_commit_sha":null,"homepage":"","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/Lupennat.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2022-12-28T10:55:20.000Z","updated_at":"2024-09-27T15:58:27.000Z","dependencies_parsed_at":"2024-10-11T09:41:29.297Z","dependency_job_id":null,"html_url":"https://github.com/Lupennat/lupdo-postgres","commit_stats":{"total_commits":18,"total_committers":1,"mean_commits":18.0,"dds":0.0,"last_synced_commit":"59bc7ac226f8ba6ad1dec9f75f58b983641f8b1a"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/Lupennat/lupdo-postgres","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lupennat%2Flupdo-postgres","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lupennat%2Flupdo-postgres/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lupennat%2Flupdo-postgres/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lupennat%2Flupdo-postgres/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Lupennat","download_url":"https://codeload.github.com/Lupennat/lupdo-postgres/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lupennat%2Flupdo-postgres/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28624341,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T02:47:06.670Z","status":"ssl_error","status_checked_at":"2026-01-21T02:45:44.886Z","response_time":86,"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":["abstraction-layer","database","lupdo","nodejs","pdo","pg","pgsql","postgres","postgres11","postgres12","postgres13","postgres14","postgres15","postgresql","transactions"],"created_at":"2024-09-27T18:21:37.173Z","updated_at":"2026-01-21T03:02:19.792Z","avatar_url":"https://github.com/Lupennat.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n \u003ca href=\"https://www.npmjs.com/package/lupdo-postgres\" target=\"__blank\"\u003e\n        \u003cimg src=\"https://img.shields.io/npm/v/lupdo-postgres?color=0476bc\u0026label=\" alt=\"NPM version\"\u003e\n    \u003c/a\u003e\n \u003ca href=\"https://www.npmjs.com/package/lupdo-postgres\" target=\"__blank\"\u003e\n        \u003cimg alt=\"NPM Downloads\" src=\"https://img.shields.io/npm/dm/lupdo-postgres?color=3890aa\u0026label=\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://app.codecov.io/github/Lupennat/lupdo-postgres\" target=\"__blank\"\u003e\n        \u003cimg src=\"https://codecov.io/github/Lupennat/lupdo-postgres/branch/main/graph/badge.svg?token=64B998KKDF\"/\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://snyk.io/test/github/lupennat/lupdo-postgres\" target=\"__blank\"\u003e\n        \u003cimg src=\"https://snyk.io/test/github/lupennat/lupdo-postgres/badge.svg\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n# Lupdo-postgres\n\n[Lupdo](https://www.npmjs.com/package/lupdo) Driver For PostgreSql and CockroachDB.\n[Api](https://lupdo-postgres.lupennat.com/api/functions/createPostgresPdo.html)\n\n## Supported Databases\n\n- [postgreSql](https://www.postgresql.org/) (v12,v13,v14,v15,v16)\n- [CockroachDB](https://www.cockroachlabs.com/) (v23.1,v23.2,v24.1,v24.2)\n\n## Third Party Library\n\nLupdo-postgres, under the hood, uses stable and performant npm packages:\n\n- [node-postgres](https://node-postgres.com/)\n\n## Usage\n\nBase Example\n\n```js\nconst { createPostgresPdo } = require('lupdo-postgres');\n// ES6 or Typescrypt\nimport { createPostgresPdo } from 'ludpo-postgres';\n\nconst pdo = createPostgresPdo(\n    {\n        host: 'localhost',\n        port: 5432,\n        user: 'user',\n        password: 'password',\n        database: 'database'\n    },\n    { min: 2, max: 3 }\n);\n\nconst run = async () =\u003e {\n    const statement = await pdo.query('SELECT 2');\n    const res = statement.fetchArray().all();\n    console.log(res);\n    await pdo.disconnect();\n};\n\nrun();\n```\n\n## Driver Options\n\n[https://node-postgres.com/apis/client](https://node-postgres.com/apis/client)\n\n\u003e **Note**\n\u003e The `host` option also accepts a list of `host:port` the pool will generate the connection using a random host from the list.\n\n## Pg Overrides\n\nBy default Ludpo-sqlite overrides user connection options with this:\n\n```ts\n{\n    types: customParser;\n}\n```\n\nLupdo postgres has a custom type parser\n\n- `boolean` are returned as number 1 or 0\n- `int8` are returned as number or BigInt when necessary\n- `bytea` are returned as Buffer\n- all others types are always returned as string\n- array are returned as Javascript `Array` of corresponding parsed type\n\n## Parameters Binding\n\nLupdo-postgres ignore type definition of `TypeBinding` parameter.\\\nLupdo-postgres support array of parameters.\n\n## Postgres Named Parameter\n\nLupdo-postgres support named parameter with syntax `:name`, through the package [yesql](https://github.com/pihvi/yesql)\n\n## Postgres Numeric Parameter\n\nLupdo-postgres support numeric parameter with syntax `?`, you can escape it using syntax `??`.\n\n## Kill Connection\n\nLupdo-postgres support kill query (only for Postgress Database not CockroachDB).\n\n## Postgres Returing\n\nLupdo-postgres support queries with `returning`, results can be fetched from statement.\n\n```ts\nconst stmt = pdo.query(\"INSERT INTO users (name, gender) VALUES ('Claudio', 'All') returning *;\");\nconsole.log(stmt.fetchArray().all());\n/*\n[\n    [33, 'Claudio', 'All']\n]\n*/\n```\n\n## Postgres lastInsertId\n\nWhen `pdo.query()` is executed outside a transaction, lupdo-postgres automatically try to fetch LastInsertId and if available it will return last id when `stmt.lastInsertId()` is called.\n\nLupdo-postgres can fetch LastInsertId on real-time when called inside a `transaction` or when statement is prepared through `pdo.prepare()`.\\\nIf you pass sequence name as parameter, it should retrieve current session value of sequence.\n\n\u003e **Warning**\n\u003e Calling `stmt.lastInsertId(name?)` inside a transaction or from a PreparedStatement, will raise an error if value is not defined inside current session.\n\n\u003e **Note**\n\u003e You can always get insert ID through [`insert returing`](#postgres-returing) syntax.\n\n## Postgres Prepared Statement\n\nPostgres support [prepared statement](https://node-postgres.com/features/queries#prepared-statements) however, it requires that the statement be prepared only at first execution, which makes it impossible to intercept syntax errors in the query before it is executed.\n\nPrepared Statement require a unique-name for each prepared statement, under the hood this is done automatically by lupdo-postgres through the package [uuid-by-string](https://github.com/Danakt/uuid-by-string)\n\n## PostgresDriver Subscribe\n\nPostgresDriver expose two static method to subscribe/unsuscribe [notification](https://www.postgresql.org/docs/current/sql-notify.html)\n\n```ts\nconst { PostgresDriver } = require('lupdo-postgres');\n// ES6 or Typescrypt\nimport { PostgresDriver } from 'ludpo-postgres';\n\nconst testSubscription = message =\u003e {\n    console.log(message);\n};\n\nPostgresDriver.subscribe('test_channel', testSubscription);\nPostgresDriver.unsubscribe('test_channel', testSubscription);\n```\n\nmessage received is of type [Notification](https://node-postgres.com/apis/client#notification)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flupennat%2Flupdo-postgres","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flupennat%2Flupdo-postgres","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flupennat%2Flupdo-postgres/lists"}