{"id":19365689,"url":"https://github.com/ryanleecode/postgres-error-codes","last_synced_at":"2025-04-23T14:31:23.142Z","repository":{"id":57109699,"uuid":"230787791","full_name":"ryanleecode/postgres-error-codes","owner":"ryanleecode","description":"Postgres Error Codes","archived":false,"fork":false,"pushed_at":"2020-12-30T13:07:35.000Z","size":29,"stargazers_count":26,"open_issues_count":1,"forks_count":9,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-18T16:57:07.588Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":false,"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/ryanleecode.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}},"created_at":"2019-12-29T18:24:46.000Z","updated_at":"2025-03-18T10:53:28.000Z","dependencies_parsed_at":"2022-08-20T20:20:17.715Z","dependency_job_id":null,"html_url":"https://github.com/ryanleecode/postgres-error-codes","commit_stats":null,"previous_names":["drdgvhbh/postgres-error-codes"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanleecode%2Fpostgres-error-codes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanleecode%2Fpostgres-error-codes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanleecode%2Fpostgres-error-codes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanleecode%2Fpostgres-error-codes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryanleecode","download_url":"https://codeload.github.com/ryanleecode/postgres-error-codes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250451722,"owners_count":21432880,"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":[],"created_at":"2024-11-10T07:41:54.271Z","updated_at":"2025-04-23T14:31:22.790Z","avatar_url":"https://github.com/ryanleecode.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Postgres Error Codes\n\n![actions-badge](https://github.com/drdgvhbh/postgres-error-codes/workflows/CI/badge.svg)\n\nPostgres error codes mapping for NodeJS.\n\n## Install\n```\nnpm i @drdgvhbh/postgres-error-codes\n```\n\n## Usage\n\nEach condition from the [PG documentation](https://www.postgresql.org/docs/9.2/errcodes-appendix.html) is available in the module. In order to obtain the status code use the prefixed uppercase condition name:\n\n`unique_violation` =\u003e `PG_UNIQUE_VIOLATION`\n\n`not_null_violation` =\u003e `PG_NOT_NULL_VIOLATION`\n\n```javascript\nconst { PG_UNIQUE_VIOLATION, PG_NOT_NULL_VIOLATION } = require('postgres-error-codes')\n\nasync function createUserMethod(req, res, next) {\n    try {\n        // Run insert user SQL\n    } catch (err) {\n        // If user with same email already exists\n        if (err.code === PG_UNIQUE_VIOLATION) {\n            return next('Email already exists!')\n        }\n\n        // Param should not be null\n        if (err.code === PG_NOT_NULL_VIOLATION) {\n            return next('Email required!')\n        }\n\n        next(err)\n    }\n}\n```\n\n## Related\n- [PostgreSQL Error Codes Documentation](https://www.postgresql.org/docs/9.2/errcodes-appendix.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanleecode%2Fpostgres-error-codes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryanleecode%2Fpostgres-error-codes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanleecode%2Fpostgres-error-codes/lists"}