{"id":18807013,"url":"https://github.com/zriyansh/node-psql","last_synced_at":"2025-10-30T13:02:56.950Z","repository":{"id":184632823,"uuid":"672179089","full_name":"zriyansh/node-psql","owner":"zriyansh","description":null,"archived":false,"fork":false,"pushed_at":"2023-07-31T10:40:15.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-29T21:30:00.413Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zriyansh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-07-29T07:20:47.000Z","updated_at":"2023-07-29T07:26:58.000Z","dependencies_parsed_at":"2024-12-29T21:29:14.090Z","dependency_job_id":"dd43ddd2-a1fe-4762-aad8-26a0d7c20cea","html_url":"https://github.com/zriyansh/node-psql","commit_stats":null,"previous_names":["zriyansh/node-psql"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zriyansh%2Fnode-psql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zriyansh%2Fnode-psql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zriyansh%2Fnode-psql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zriyansh%2Fnode-psql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zriyansh","download_url":"https://codeload.github.com/zriyansh/node-psql/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239742417,"owners_count":19689309,"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-07T22:50:34.673Z","updated_at":"2025-10-30T13:02:56.943Z","avatar_url":"https://github.com/zriyansh.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node.js PostgreSQL CRUD example with Express Rest APIs\n\n\nrequired .env with values\n```\nHOST=\nUSER=postgres\nPASSWORD=\nDB=testdb\nDIALECT=postgres\nPOOL_MAX=5\nPOOL_MIN=0\nPOOL_ACQUIRE=30000\nPOOL_IDLE=10000\n```\n\nrequired .env with values for localhost\n```\nHOST=localhost\nUSER=postgres\nPASSWORD=123\nDB=testdb\nDIALECT=postgres\nPOOL_MAX=5\nPOOL_MIN=0\nPOOL_ACQUIRE=30000\nPOOL_IDLE=10000\n```\n\nWe will build Rest Apis that can create, retrieve, update, delete and find Tutorials by title.\n\nThe following table shows overview of the Rest APIs that will be exported:\n\n- GET     `api/tutorials`\t            get all Tutorials\n- GET     `api/tutorials/:id`         get Tutorial by id\n- POST    `api/tutorials`             add new Tutorial\n- PUT     `api/tutorials/:id`         update Tutorial by id\n- DELETE  `api/tutorials/:id`         remove Tutorial by id\n- DELETE  `api/tutorials`             remove all Tutorials\n- GET     `api/tutorials/published`   find all published Tutorials\n- GET     `api/tutorials?title=[kw]`  find all Tutorials which title contains 'kw'\n\nCreate a new Tutorial using `POST /tutorials` Api. Make sure to select BODY\u003eRAW\u003eJSON\n\n![node-js-postgresql-crud-example-create](https://dev-to-uploads.s3.amazonaws.com/i/hqvz8ra9p21z927iwzph.png)\n\nAfter creating some new Tutorials, you can check PostgreSQL table:\n```testdb=# select * from tutorials;\n id |    title    |    description    | published |         createdAt          |         updatedAt\n----+-------------+-------------------+-----------+----------------------------+----------------------------\n  1 | Node Tut #1 | Tut#1 Description | f         | 2020-01-29 10:42:57.121+07 | 2020-01-29 10:42:57.121+07\n  2 | Node Tut #2 | Tut#2 Description | f         | 2020-01-29 10:43:05.131+07 | 2020-01-29 10:43:05.131+07\n  3 | Node Tut #3 | Tut#3 Description | f         | 2020-01-29 10:43:48.028+07 | 2020-01-29 10:43:48.028+07\n  4 | Js Tut #4   | Tut#4 Desc        | f         | 2020-01-29 10:45:40.016+07 | 2020-01-29 10:45:40.016+07\n  5 | Js Tut #5   | Tut#5 Desc        | f         | 2020-01-29 10:45:44.289+07 | 2020-01-29 10:45:44.289+07\n```\n\n- Retrieve all Tutorials using `GET /tutorials` Api\n\n![node-js-postgresql-crud-example-retrieve-all](https://dev-to-uploads.s3.amazonaws.com/i/m9razjm1njgww58er3as.png)\n\n- Retrieve a single Tutorial by id using `GET /tutorials/:id` Api\n\n![node-js-postgresql-crud-example-retrieve-one](https://dev-to-uploads.s3.amazonaws.com/i/0kuojvc596i5u423od2b.png)\n\n- Update a Tutorial using `PUT /tutorials/:id` Api\n\n![node-js-postgresql-crud-example-update](https://dev-to-uploads.s3.amazonaws.com/i/3buqfz0by0lu2z4kf3uq.png)\n\nCheck `tutorials` table after some rows were updated:\n```testdb=# select * from tutorials;\n id |     title      |    description    | published |         createdAt          |         updatedAt\n----+----------------+-------------------+-----------+----------------------------+----------------------------\n  1 | Node Tut #1    | Tut#1 Description | f         | 2020-01-29 10:42:57.121+07 | 2020-01-29 10:42:57.121+07\n  3 | Node Tut #3    | Tut#3 Description | f         | 2020-01-29 10:43:48.028+07 | 2020-01-29 10:43:48.028+07\n  2 | Node Js Tut #2 | Tut#2 Description | t         | 2020-01-29 10:43:05.131+07 | 2020-01-29 10:51:55.235+07\n  4 | Js Tut #4      | Tut#4 Desc        | t         | 2020-01-29 10:45:40.016+07 | 2020-01-29 10:54:17.468+07\n  5 | Js Tut #5      | Tut#5 Desc        | t         | 2020-01-29 10:45:44.289+07 | 2020-01-29 10:54:20.544+07\n```\n\n- Find all Tutorials which title contains 'js': `GET /tutorials?title=js`\n\n![node-js-postgresql-crud-example-search](https://dev-to-uploads.s3.amazonaws.com/i/u2hbmz5r35o7uo09y3z5.png)\n\n- Find all published Tutorials using `GET /tutorials/published` Api\n\n![node-js-postgresql-crud-example-search-status](https://dev-to-uploads.s3.amazonaws.com/i/dbo753wfqibt0b93d82d.png)\n\n- Delete a Tutorial using `DELETE /tutorials/:id` Api\n\n![node-js-postgresql-crud-example-delete-one](https://dev-to-uploads.s3.amazonaws.com/i/pyos3wq4tchb8ixuyj1c.png)\n\nTutorial with id=4 was removed from `tutorials` table:\n```testdb=# select * from tutorials;\n id |     title      |    description    | published |         createdAt          |         updatedAt\n----+----------------+-------------------+-----------+----------------------------+----------------------------\n  1 | Node Tut #1    | Tut#1 Description | f         | 2020-01-29 10:42:57.121+07 | 2020-01-29 10:42:57.121+07\n  3 | Node Tut #3    | Tut#3 Description | f         | 2020-01-29 10:43:48.028+07 | 2020-01-29 10:43:48.028+07\n  2 | Node Js Tut #2 | Tut#2 Description | t         | 2020-01-29 10:43:05.131+07 | 2020-01-29 10:51:55.235+07\n  5 | Js Tut #5      | Tut#5 Desc        | t         | 2020-01-29 10:45:44.289+07 | 2020-01-29 10:54:20.544+07\n```\n\n- Delete all Tutorials using `DELETE /tutorials` Api\n\n![node-js-postgresql-crud-example-delete-all](https://dev-to-uploads.s3.amazonaws.com/i/ga42747jorssl20ywyug.png)\n\nNow there are no rows in `tutorials` table:\n```testdb=# select * from tutorials;\n id | title | description | published | createdAt | updatedAt\n----+-------+-------------+-----------+-----------+-----------\n```\n\n## Project setup\n```\nnpm install\n```\n\n### Run\n```\nnode server.js\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzriyansh%2Fnode-psql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzriyansh%2Fnode-psql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzriyansh%2Fnode-psql/lists"}