{"_id":"@drdgvhbh/postgres-error-codes","_rev":"1-5f86d442de90a8793a7c3f2013b95205","name":"@drdgvhbh/postgres-error-codes","dist-tags":{"latest":"0.0.6"},"versions":{"0.0.6":{"name":"@drdgvhbh/postgres-error-codes","version":"0.0.6","description":"Postgres Error Codes","main":"lib/index.js","keywords":["postgres","nodejs","error","codes"],"author":{"name":"Ryan Lee","email":"ryanleecode@gmail.com","url":"https://rlee.dev"},"repository":{"type":"git","url":"git+https://github.com/drdgvhbh/postgres-error-codes.git"},"license":"MIT","bugs":{"url":"https://github.com/drdgvhbh/postgres-error-codes/issues"},"homepage":"https://github.com/drdgvhbh/postgres-error-codes#readme","dependencies":{},"scripts":{"prepublishOnly":"npm run clean && npm run build","prepare":"npm run build","clean":"rimraf lib","build":"tsc","lint":"eslint \"./**/*.{ts,js}\"","lint:fix":"eslint --fix \"./**/*.{ts,js}\""},"devDependencies":{"@typescript-eslint/eslint-plugin":"^2.13.0","@typescript-eslint/parser":"^2.13.0","eslint":"^6.8.0","eslint-config-prettier":"^6.9.0","eslint-plugin-prettier":"^3.1.2","prettier":"^1.19.1","rimraf":"^3.0.0","typescript":"^3.7.4"},"gitHead":"60c61fdbeebafe4ecf4bf0d6c4f8822dfba6d721","_id":"@drdgvhbh/postgres-error-codes@0.0.6","_nodeVersion":"13.1.0","_npmVersion":"6.12.1","dist":{"integrity":"sha512-tAz0Xp+qhq90x0r/3VW96iRdHFw72cYQqXa65u0eFVhSMC27bc2gZ8Ky5WXEmshrl/bCe7QTYBNEF0U5zeSQjw==","shasum":"ff1c6258771894c5c7662495531c38b46e1cc037","tarball":"https://registry.npmjs.org/@drdgvhbh/postgres-error-codes/-/postgres-error-codes-0.0.6.tgz","fileCount":12,"unpackedSize":47605,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeCPI+CRA9TVsSAnZWagAA17QP/2TOOyEDgbK28+1eOGMR\nVRrxvtCNG+xE2dh69SeBZZ6XRb4OZrnW4GEBkPt4hnaoQzz/MoO1wHWcBfrO\nc+xTPnIK/z5NphL7TyVvJOj3mzej1Fi+sb6bWCU+CyXdreGqZdmDyriJTeBL\nza7fvoHMqLAPYQPuszAxn8pK/vcWLePlPqV6XtESC0JmXSAo9yr7SqL+sR4r\nnGs3JNR1rqwOZ7kKXXkGcD2Afdp/8BWFZYWiO5IA/ZNOWxPbqOk4mQMhaCFx\nZk1lWY0/gMSApOqBZYtzU6SlcUyyjJik6JsXeZuthMWaubtZOR0eXChG5Oc3\nU2vTekJTawC0p+DawegTi1n6IEaBBVA8kFjZrihLK6JSXHJCC2m7BwEqUE5X\n6Uo8w64JzbROdtr0jU3k80NxzS5DR5s9+k8E0imm4e19w1/WBEIWv2QzYu+2\nrKX+QZgy3XLtfXjJhSP+e3jWqbwMVTUIN4q1CjjJoX63nrv19FkEGq93Gnw+\nyJh2cX55vLK6mMJ2WKirIIcwLSH2Oor5Gb+8/Ka5QR604INYEnZ10MX6/oZW\noARufb9eMNd7KowuhNplmhdnCQDqGYMSK5K+I3lgTbUJnj2E7RlBnaCT3p3p\n5ksJ18mQobQE3McOwdiw7feubVemgvGvPf5f2mUNfFtKCGsBokrA5Dk+gIxI\n9Ybc\r\n=sxMN\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCC3me5bughsCd1fEUABySNRkr/MpiJ5w2mB3gP3MwklgIgDQuGjckydU+Xfn8zTzTi4fjen3cZC5c7v5Fk/wb/UZY="}]},"maintainers":[{"name":"drdgvhbh","email":"drdgvhbh@gmail.com"}],"_npmUser":{"name":"drdgvhbh","email":"drdgvhbh@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/postgres-error-codes_0.0.6_1577644606039_0.12440742823891071"},"_hasShrinkwrap":false}},"time":{"created":"2019-12-29T18:36:46.000Z","0.0.6":"2019-12-29T18:36:46.226Z","modified":"2022-04-05T05:37:13.855Z"},"maintainers":[{"name":"drdgvhbh","email":"drdgvhbh@gmail.com"}],"description":"Postgres Error Codes","homepage":"https://github.com/drdgvhbh/postgres-error-codes#readme","keywords":["postgres","nodejs","error","codes"],"repository":{"type":"git","url":"git+https://github.com/drdgvhbh/postgres-error-codes.git"},"author":{"name":"Ryan Lee","email":"ryanleecode@gmail.com","url":"https://rlee.dev"},"bugs":{"url":"https://github.com/drdgvhbh/postgres-error-codes/issues"},"license":"MIT","readme":"# Postgres Error Codes\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` => `PG_UNIQUE_VIOLATION`\n\n`not_null_violation` => `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","readmeFilename":"README.md"}