{"_id":"@customer01annapooranisarees/postgres-query-builder","_rev":"1-17f32bf7b891e0e85bdbce188d263944","name":"@customer01annapooranisarees/postgres-query-builder","dist-tags":{"latest":"1.2.0"},"versions":{"1.2.1":{"name":"@customer01annapooranisarees/postgres-query-builder","version":"1.2.1","keywords":["PostgreSQL","query builder","PostgreSQL query builder","nodejs PostgreSQL query builder"],"author":{"url":"https://annapoorani.io/","name":"The Nguyen"},"license":"MIT","_id":"@customer01annapooranisarees/postgres-query-builder@1.2.1","maintainers":[{"name":"customer01annapooranisarees","email":"customer01annapooranisarees@gmail.com"}],"homepage":"https://github.com/customer01annapooranisarees/customer01annapooranisarees/tree/main/packages/postgres-query-builder","bugs":{"url":"https://github.com/customer01annapooranisarees/customer01annapooranisarees/issues"},"dist":{"shasum":"7abee56ca6079a36130ca0102c53d5566ace1920","tarball":"https://registry.npmjs.org/@customer01annapooranisarees/postgres-query-builder/-/postgres-query-builder-1.2.1.tgz","fileCount":7,"integrity":"sha512-1urp2k+4X2afEn1rQirJQ3Nne40sVvbosOuIuDn8JRi5N3STUyZxHY4FfnLBZOdxYCd4DraAXnAW7yZmDaqutg==","signatures":[{"sig":"MEYCIQCS2lQdCPa5g4vaMT07EeOiIrEdACG3+F407tdugZlWywIhAK5cdc6i2AC8ZRekuzMfbSFPF1+Pt640dVZhylV+XmY/","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":31646},"main":"index.js","engines":{"node":">= 12.0.0"},"gitHead":"b99afe42789378aa1fb2757b5ac1a457fc38e834","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"customer01annapooranisarees","email":"customer01annapooranisarees@gmail.com"},"repository":{"url":"git+https://github.com/customer01annapooranisarees/customer01annapooranisarees.git#main","type":"git"},"_npmVersion":"10.9.1","description":"A PostgreSQL query builder for NodeJS","directories":{},"_nodeVersion":"23.3.0","dependencies":{"pg":"^8.10.0","uniqid":"^5.3.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/postgres-query-builder_1.2.1_1732873797264_0.9957679626276472","host":"s3://npm-registry-packages"}},"1.2.0":{"name":"@customer01annapooranisarees/postgres-query-builder","version":"1.2.0","description":"A PostgreSQL query builder for NodeJS","main":"index.js","repository":{"type":"git","url":"git+https://github.com/customer01annapooranisareescommerce/customer01annapooranisarees.git#main"},"keywords":["PostgreSQL","query builder","PostgreSQL query builder","nodejs PostgreSQL query builder"],"author":{"name":"The Nguyen","url":"https://customer01annapooranisarees.io/"},"license":"MIT","bugs":{"url":"https://github.com/customer01annapooranisareescommerce/customer01annapooranisarees/issues"},"homepage":"https://github.com/customer01annapooranisareescommerce/customer01annapooranisarees/tree/main/packages/postgres-query-builder","dependencies":{"pg":"^8.10.0","uniqid":"^5.3.0"},"engines":{"node":">= 12.0.0"},"_id":"@customer01annapooranisarees/postgres-query-builder@1.2.0","gitHead":"3ba9b59d5c19825d4f483a60c2ac87bd61ccdbb0","_nodeVersion":"23.3.0","_npmVersion":"10.9.1","dist":{"integrity":"sha512-r8tnLUjXjW8ixizAIkDTBCqeZNucgXctdnXaTdkkieSjVnkSh0mhjYcc4bti1VVm1Mm/YBcR/yo12w30jwfzJA==","shasum":"c3ba9ce6b9fed9145c90486342f934a81d8f90d0","tarball":"https://registry.npmjs.org/@customer01annapooranisarees/postgres-query-builder/-/postgres-query-builder-1.2.0.tgz","fileCount":7,"unpackedSize":31640,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGDznvLgBi1+vgHd/hSjlNNadDm0UkErtyRARcmKIFKRAiEA7hRZjKmtpAtmJfEls7fAv8NSnJyZxxTIqUj8lmB4L9o="}]},"_npmUser":{"name":"customer01annapooranisarees","email":"customer01annapooranisarees@gmail.com"},"directories":{},"maintainers":[{"name":"customer01annapooranisarees","email":"customer01annapooranisarees@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/postgres-query-builder_1.2.0_1732930337637_0.8692713649953785"},"_hasShrinkwrap":false}},"time":{"created":"2024-11-29T09:49:57.135Z","modified":"2024-11-30T01:32:17.968Z","1.2.1":"2024-11-29T09:49:57.421Z","1.2.0":"2024-11-30T01:32:17.801Z"},"bugs":{"url":"https://github.com/customer01annapooranisareescommerce/customer01annapooranisarees/issues"},"author":{"name":"The Nguyen","url":"https://customer01annapooranisarees.io/"},"license":"MIT","homepage":"https://github.com/customer01annapooranisareescommerce/customer01annapooranisarees/tree/main/packages/postgres-query-builder","keywords":["PostgreSQL","query builder","PostgreSQL query builder","nodejs PostgreSQL query builder"],"repository":{"type":"git","url":"git+https://github.com/customer01annapooranisareescommerce/customer01annapooranisarees.git#main"},"description":"A PostgreSQL query builder for NodeJS","maintainers":[{"name":"customer01annapooranisarees","email":"customer01annapooranisarees@gmail.com"}],"readme":"# PostgreSQL query builder for Node\n\nA PostgreSQL query builder for NodeJS. \n\n## Installation\n\n```javascript\nnpm install @customer01annapooranisarees/postgres-query-builder\n```\n\n## Usage guide\nIt implements async/await.\n### Simple select\n\n```javascript\nconst {select} = require('@customer01annapooranisarees/postgres-query-builder')\n\nconst products = await select(\"*\")\n.from(\"product\")\n.where(\"product_id\", \">\", 1)\n.execute(pool);\n```\n### More complex where\n```javascript\nconst {select} = require('@customer01annapooranisarees/postgres-query-builder')\n\nconst products = await select(\"*\")\n.from(\"product\")\n.where(\"product_id\", \">\", 1)\n.and(\"sku\", \"LIKE\", \"sku\")\n.execute(pool);\n```\n### Event more complex where\n```javascript\nconst {select} = require('@customer01annapooranisarees/postgres-query-builder')\n\nconst query = select(\"*\").from(\"product\");\nquery.where(\"product_id\", \">\", 1).and(\"sku\", \"LIKE\", \"sku\");\nquery.orWhere(\"price\", \">\", 100);\n\nconst products = await query.execute(pool);\n```\n\n### Join table\n```javascript\nconst {select} = require('@customer01annapooranisarees/postgres-query-builder')\n\nconst query = select(\"*\").from(\"product\");\nquery.leftJoin('price').on('product.`product_id`', '=', 'price.`product_id`');\nquery.where(\"product_id\", \">\", 1).and(\"sku\", \"LIKE\", \"sku\");\nquery.andWhere(\"price\", \">\", 100);\n\nconst products = await query.execute(pool);\n```\n\n### Insert&update\n<table>\n<tr>\n<th> user_id </th>\n<th> name </th>\n<th> email </th>\n<th> phone </th>\n<th> status </th>\n</tr>\n<tr>\n<td>\n  1\n</td>\n<td>\n  David\n</td>\n<td>\n  emai@email.com\n</td>\n<td>\n  123456\n</td>\n<td>\n  1\n</td>\n</tr>\n</table>\n\n```javascript\n```javascript\nconst {insert} = require('@customer01annapooranisarees/postgres-query-builder')\n\nconst query = insert(\"user\")\n.given({name: \"David\", email: \"email@email.com\", \"phone\": \"123456\", status: 1, notExistedColumn: \"This will not be a part of the query\"});\nawait query.execute(pool);\n```\n```javascript\nconst {update} = require('@customer01annapooranisarees/postgres-query-builder')\n\nconst query = update(\"user\")\n.given({name: \"David\", email: \"email@email.com\", \"phone\": \"123456\", status: 1, notExistedColumn: \"This will not be a part of query\"})\n.where(\"user_id\", \"=\", 1);\nawait query.execute(pool);\n```\n### Working with transaction\n\n```javascript\nconst { Pool } = require('pg');\nconst {insert, getConnection, startTransaction, commit, rollback} = require('@customer01annapooranisarees/postgres-query-builder');\n\nconst pool = new Pool(connectionSetting);\n\n// Create a connection from the pool\nconst connection = await getConnection(pool);\n\n// Start a transaction\nawait startTransaction(connection);\ntry {\n  await insert(\"user\")\n        .given({name: \"David\", email: \"email@email.com\", \"phone\": \"123456\", status: 1, notExistedColumn: \"This will not be a part of the query\"})\n        .execute(connection);\n  await commit(connection);\n} catch(e) {\n  await rollback(connection);\n}\n```\n## Security\n\nAll user provided data will be escaped.","readmeFilename":"README.md"}