{"id":25860935,"url":"https://github.com/pom4h/pg-query-config","last_synced_at":"2025-03-01T23:03:19.854Z","repository":{"id":57322630,"uuid":"268577216","full_name":"Pom4H/pg-query-config","owner":"Pom4H","description":"Query Builder for PostgreSQL. With jsonb support. Written in TypeScript.","archived":false,"fork":false,"pushed_at":"2021-09-27T14:02:35.000Z","size":25,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-01T23:02:55.556Z","etag":null,"topics":["jsonb","postgresql","typescript"],"latest_commit_sha":null,"homepage":"","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/Pom4H.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":"2020-06-01T16:41:16.000Z","updated_at":"2023-02-02T05:47:52.000Z","dependencies_parsed_at":"2022-08-25T21:01:06.718Z","dependency_job_id":null,"html_url":"https://github.com/Pom4H/pg-query-config","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pom4H%2Fpg-query-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pom4H%2Fpg-query-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pom4H%2Fpg-query-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pom4H%2Fpg-query-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Pom4H","download_url":"https://codeload.github.com/Pom4H/pg-query-config/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241435161,"owners_count":19962404,"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":["jsonb","postgresql","typescript"],"created_at":"2025-03-01T23:03:18.912Z","updated_at":"2025-03-01T23:03:19.826Z","avatar_url":"https://github.com/Pom4H.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Query Builder for PostgreSQL\nWith jsonb support. Written in TypeScript.\n\n#### install\n\n```\nnpm install pg-query-config\n```\n\n#### example\n\n```javascript\nconst { QueryConfig } = require('pg-query-config');\nconst db = require('./myPgClient'); // pg or typeorm\n\nconst query = new QueryConfig({ table: 'account' });\n\nquery.where({ status: 'active', profile: { name: ['John', 'Peter'], email: 'example@mail.com' } });\n\nquery.text // SELECT * FROM account WHERE status = $1 AND profile-\u003e\u003e'name' IN ($2,$3) AND profile-\u003e\u003e'email' = $4\nquery.values // [ 'active', 'John', 'Peter', 'example@mail.com' ]\n\ndb.query(query);\n```\n\n#### typescript example\n\n```javascript\nimport { QueryConfig, LeftContain } from 'pg-query-config';\n\ntype Color = 'black' | 'white' | 'blue' | 'red';\ntype Brand = 'BMW' | 'Audi' | 'TOYOTA';\ntype Engine = {\n    cylinders: number;\n    hp: number;\n};\ntype Car = {\n    brand: Brand;\n    color: Color;\n    engine: Engine;\n};\ntype User = {\n    id: number;\n    name: string;\n    car: Car;\n};\n\nconst query = new QueryConfig\u003cUser\u003e({ table: 'car_user' });\n\nquery\n    .select(['name', 'car'])\n    .where({ id: 100 })\n    .orWhere([\n        { car: { engine: LeftContain({ hp: 500 }) } }, \n        { car: { engine: LeftContain({ cylinders: 8 }) } }\n    ]);\n\nquery.text // SELECT name,car FROM car_user WHERE id = $1 AND (car-\u003e\u003e'engine' @\u003e $2 OR car-\u003e\u003e'engine' @\u003e $3)\nquery.values // [ 100, '{\"hp\":500}', '{\"cylinders\":8}' ]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpom4h%2Fpg-query-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpom4h%2Fpg-query-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpom4h%2Fpg-query-config/lists"}