{"id":17761054,"url":"https://github.com/panates/postgrejs","last_synced_at":"2025-04-13T02:50:55.204Z","repository":{"id":37366120,"uuid":"303497185","full_name":"panates/postgrejs","owner":"panates","description":"Professional PostgreSQL client for NodeJS","archived":false,"fork":false,"pushed_at":"2024-08-20T17:35:00.000Z","size":2564,"stargazers_count":48,"open_issues_count":2,"forks_count":12,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-08-21T10:27:41.421Z","etag":null,"topics":["client","connector","driver","javascript","nodejs","pg","postgres","postgresql","typescript"],"latest_commit_sha":null,"homepage":"https://postgrejs.panates.com","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/panates.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"support/package.cjs.json","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-12T19:48:27.000Z","updated_at":"2024-08-20T17:35:05.000Z","dependencies_parsed_at":"2023-01-30T17:45:18.181Z","dependency_job_id":"d71d9236-6054-46f6-8e26-7c2affa7b258","html_url":"https://github.com/panates/postgrejs","commit_stats":{"total_commits":217,"total_committers":4,"mean_commits":54.25,"dds":0.4470046082949308,"last_synced_commit":"9985c3eeedb514d6f11c017008869b8d95c2853c"},"previous_names":["panates/postgrejs","panates/postgresql-client"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panates%2Fpostgrejs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panates%2Fpostgrejs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panates%2Fpostgrejs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panates%2Fpostgrejs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/panates","download_url":"https://codeload.github.com/panates/postgrejs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248657870,"owners_count":21140844,"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":["client","connector","driver","javascript","nodejs","pg","postgres","postgresql","typescript"],"created_at":"2024-10-26T19:18:55.103Z","updated_at":"2025-04-13T02:50:54.985Z","avatar_url":"https://github.com/panates.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--suppress HtmlDeprecatedAttribute --\u003e\n\u003cp align=\"center\"\u003e¨\n  \u003ca href=\"https://postgrejs.panates.com/\" target=\"blank\"\u003e\n    \u003cimg src=\"https://postgrejs.panates.com/img/postgrejs-header-block.png\" width=\"800\" alt=\"PostgreJS Logo\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n  \n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n[![CI Tests][ci-test-image]][ci-test-url]\n[![Test Coverage][coveralls-image]][coveralls-url]\n\n\nPostgreJS is an enterprise-level PostgreSQL client for Node.js.\nIt is designed to provide a robust and efficient interface to PostgreSQL databases,\nensuring high performance and reliability for enterprise applications.\nWritten entirely in TypeScript, it leverages modern JavaScript features to deliver a seamless development experience.\n\n\n## Library Overview\n\nPostgreJS is a pure JavaScript library, meticulously crafted with TypeScript to offer a strictly typed, well-structured,\nand highly maintainable codebase.\nKey highlights include:\n\n- **Language:** Pure modern JavaScript library.\n- **Strictly Typed:** Completely written in TypeScript, offering strong typing and enhanced development experience.\n- **Compatibility:** Works seamlessly with both CommonJS and ESM module systems, ensuring flexibility in various project setups.\n- **Comprehensive Testing:** Rigorously tested to ensure stability and reliability in production environments.\n- **Promise-Based API:** Asynchronous operations are handled with a Promise-based API, promoting clean and efficient asynchronous code.\n\n## Features\n\n- **Connection Management:** Supports both single connection and advanced pooling, providing scalability and efficient resource management.\n- **Binary Wire Protocol:** Implements the full binary wire protocol for all PostgreSQL data types, ensuring robust and efficient data handling.\n- **Prepared Statements:** Named prepared statements for optimized query execution.\n- **Cursors:** Features fast double-link cache cursors for efficient data retrieval.\n- **Notifications:**  High-level implementation for PostgreSQL notifications (LISTEN/NOTIFY), enabling real-time data updates.\n- **Extensibility:** Extensible data-types and type mapping to accommodate custom requirements.\n- **Parameter Binding:**  Bind parameters with OID mappings for precise and efficient query execution.\n- **Array Handling:** Supports multidimensional arrays with fast binary encoding/decoding.\n- **Performance Optimization:**  Low memory utilization and boosted performance through the use of shared buffers.\n- **Authorization:** SSupports various password algorithms including Clear text, MD5, and SASL, ensuring secure authentication.\n- **Flexible Data Retrieval:**  Can return both array and object rows to suit different data processing needs.\n- **Resource Management:** Auto disposal of resources with the \"using\" syntax ([TC30 Explicit Resource Management](https://github.com/tc39/proposal-explicit-resource-management)), ensuring efficient resource cleanup.\n\nWhether you're building a simple application or a complex enterprise system,\nPostgreJS provides the features and performance you need to succeed.\nExplore the capabilities of the library and elevate your PostgreSQL integration to the next level.\n\n\n## Installation\n\n```bash\n$ npm install postgrejs --save\n```\n\n## Documentation\nPlease read :small_orange_diamond: [DOCUMENTATION](https://postgrejs.panates.com/) :small_orange_diamond: for detailed usage.\n\n## Example usage\n\n### Establish a single connection, execute a simple query\n\n```ts\nimport { Connection } from 'postgrejs';\n// Create connection\nconst connection = new Connection('postgres://localhost');\n// Connect to database server\nawait connection.connect();\n\n// Execute query and fetch rows\nconst result = await connection.query(\n    'select * from cities where name like $1',\n    {params: ['%york%']});\nconst rows: any[] = result.rows;\n// Do what ever you want with rows\n\n// Disconnect from server\nawait connection.close(); \n```\n\n### Establish a pooled connection, create a cursor\n```ts\nimport { Pool } from 'postgrejs';\n\n// Create connection pool\nconst db = new Pool({\n    host: 'postgres://localhost',\n    pool: {\n       min: 1,\n       max: 10,\n       idleTimeoutMillis: 5000\n    }\n});\n\n// Execute query and fetch cursor\nconst result = await db.query(\n    'select * from cities where name like $1',\n    {params: ['%york%'], cursor: true});\n\n// Walk through the cursor, and do whatever you want with fetched rows\nconst cursor = result.cursor;\nlet row;\nwhile ((row = await cursor.next())) {\n  console.log(row);\n}\n// Close cursor, (Send connection back to the pool)\nawait cursor.close();\n\n// Disconnect all connections and shutdown pool\nawait db.close(); \n```\n\n### Using prepared statements\n```ts\nimport { DataTypeOIDs } from 'postgrejs'; \n\n// .....\nconst statement = await connection.prepare( \n    'insert into my_table(id, name) values ($1, $2)', {\n        paramTypes: [DataTypeOIDs.Int4, DataTypeOIDs.Varchar]\n    });\n\nfor (let i = 0; i \u003c 100; i++) {\n    await statement.execute({params: [i, ('name' + i)]});\n}\nawait statement.close(); // When you done, close the statement to relase resources\n```\n\n#### Check [DOCUMENTATION](https://postgrejs.panates.com/) for other examples.\n\n\n\n## Type mappings\nThe table below lists builtin data type mappings.\n\n| PosgtreSQL type | JS type     | Receive     | Send   | \n|-----------------|:------------|-------------|--------|\n| bool            | boolean     | text,binary | binary | \n| int2            | number      | text,binary | binary | \n| int4            | number      | text,binary | binary | \n| int8            | BigInt      | text,binary | binary | \n| float4          | number      | text,binary | binary | \n| float8          | number      | text,binary | binary | \n| char            | string      | text,binary | binary | \n| bpchar          | string      | text,binary | binary | \n| varchar         | string      | text,binary | binary | \n| date            | Date        | text,binary | binary | \n| time            | Date        | text,binary | binary | \n| timestamp       | Date        | text,binary | binary | \n| timestamptz     | Date        | text,binary | binary | \n| oid             | number      | text,binary | binary | \n| bytea           | Buffer      | text,binary | binary | \n| uuid            | string      | text,binary | binary | \n| json            | object      | text,binary | binary | \n| jsonb           | object      | text,binary | binary | \n| xml             | string      | text,binary | binary | \n| point           | Point       | text,binary | binary | \n| circle          | Circle      | text,binary | binary | \n| lseg            | Rectangle   | text,binary | binary | \n| box             | Rectangle   | text,binary | binary | \n| int2Vector      | number[]    | text,binary | binary | \n| _bool           | boolean[]   | text,binary | binary | \n| _int2           | number[]    | text,binary | binary | \n| _int4           | number[]    | text,binary | binary | \n| _int8           | BigInt[]    | text,binary | binary | \n| _float4         | number[]    | text,binary | binary | \n| _float8         | number[]    | text,binary | binary | \n| _char           | string[]    | text,binary | binary | \n| _bpchar         | string[]    | text,binary | binary | \n| _varchar        | string[]    | text,binary | binary | \n| _date           | Date[]      | text,binary | binary | \n| _time           | Date[]      | text,binary | binary | \n| _timestamp      | Date[]      | text,binary | binary | \n| _timestamptz    | Date[]      | text,binary | binary | \n| _uuid           | string[]    | text,binary | binary | \n| _oid            | number[]    | text,binary | binary | \n| _bytea          | Buffer[]    | text,binary | binary | \n| _json           | object[]    | text,binary | binary | \n| _jsonb          | object[]    | text,binary | binary | \n| _xml            | string[]    | text,binary | binary | \n| _point          | Point[]     | text,binary | binary | \n| _circle         | Circle[]    | text,binary | binary | \n| _lseg           | Rectangle[] | text,binary | binary | \n| _box            | Rectangle[] | text,binary | binary | \n| _int2Vector     | number[][]  | text,binary | binary | \n\n\n## Support\nYou can report bugs and discuss features on the [GitHub issues](https://github.com/panates/postgrejs/issues) page\nWhen you open an issue please provide version of NodeJS and PostgreSQL server.\n\n## Node Compatibility\n- node \u003e= 16.x\n \n  \n## License\nPostgreJS is available under [MIT](LICENSE) license.\n\n[npm-image]: https://img.shields.io/npm/v/postgrejs\n[npm-url]: https://npmjs.org/package/postgrejs\n[ci-test-image]: https://github.com/panates/postgrejs/actions/workflows/test.yml/badge.svg\n[ci-test-url]: https://github.com/panates/postgrejs/actions/workflows/test.yml\n[coveralls-image]: https://img.shields.io/coveralls/panates/postgrejs/master.svg\n[coveralls-url]: https://coveralls.io/r/panates/postgrejs\n[downloads-image]: https://img.shields.io/npm/dm/postgrejs.svg\n[downloads-url]: https://npmjs.org/package/postgrejs\n[gitter-image]: https://badges.gitter.im/panates/postgrejs.svg\n[gitter-url]: https://gitter.im/panates/postgrejs?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge\n[dependencies-image]: https://david-dm.org/panates/postgrejs/status.svg\n[dependencies-url]:https://david-dm.org/panates/postgrejs\n[devdependencies-image]: https://david-dm.org/panates/postgrejs/dev-status.svg\n[devdependencies-url]:https://david-dm.org/panates/postgrejs?type=dev\n[quality-image]: http://npm.packagequality.com/shield/postgrejs.png\n[quality-url]: http://packagequality.com/#?package=postgrejs\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpanates%2Fpostgrejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpanates%2Fpostgrejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpanates%2Fpostgrejs/lists"}