{"id":15889091,"url":"https://github.com/arshadkazmi42/genql","last_synced_at":"2025-10-18T00:33:04.746Z","repository":{"id":44909566,"uuid":"200090960","full_name":"arshadkazmi42/genql","owner":"arshadkazmi42","description":"Helper for sql query generation and formatting","archived":false,"fork":false,"pushed_at":"2022-10-22T20:13:09.000Z","size":110,"stargazers_count":4,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-28T23:57:19.601Z","etag":null,"topics":["generate-sql","gensql","mysql","postgresql","query","query-generator","sql","sql-query","sqlite"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/arshadkazmi42.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"arshadkazmi42"}},"created_at":"2019-08-01T17:15:01.000Z","updated_at":"2023-02-14T16:25:00.000Z","dependencies_parsed_at":"2023-01-20T07:02:27.735Z","dependency_job_id":null,"html_url":"https://github.com/arshadkazmi42/genql","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arshadkazmi42%2Fgenql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arshadkazmi42%2Fgenql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arshadkazmi42%2Fgenql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arshadkazmi42%2Fgenql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arshadkazmi42","download_url":"https://codeload.github.com/arshadkazmi42/genql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244066191,"owners_count":20392407,"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":["generate-sql","gensql","mysql","postgresql","query","query-generator","sql","sql-query","sqlite"],"created_at":"2024-10-06T06:41:13.234Z","updated_at":"2025-10-18T00:33:04.666Z","avatar_url":"https://github.com/arshadkazmi42.png","language":"JavaScript","funding_links":["https://github.com/sponsors/arshadkazmi42"],"categories":[],"sub_categories":[],"readme":"# genql\n\n[![Build](https://github.com/arshadkazmi42/genql/actions/workflows/nodejs.yml/badge.svg)](https://github.com/arshadkazmi42/genql/actions/workflows/nodejs.yml)\n[![NPM Version](https://img.shields.io/npm/v/genql.svg)](https://www.npmjs.com/package/genql)\n[![NPM Downloads](https://img.shields.io/npm/dt/genql.svg)](https://www.npmjs.com/package/genql)\n[![Github Repo Size](https://img.shields.io/github/repo-size/arshadkazmi42/genql.svg)](https://github.com/arshadkazmi42/genql)\n[![LICENSE](https://img.shields.io/npm/l/genql.svg)](https://github.com/arshadkazmi42/genql/blob/master/LICENSE)\n[![Contributors](https://img.shields.io/github/contributors/arshadkazmi42/genql.svg)](https://github.com/arshadkazmi42/genql/graphs/contributors)\n[![Commit](https://img.shields.io/github/last-commit/arshadkazmi42/genql.svg)](https://github.com/arshadkazmi42/genql/commits/master)\n\n\n\nHelper for SQL query generating and formatting\n\n## Install\n\n```\nnpm i genql\n```\n\n## Usage\n\n```javascript\n\nconst GenQL = require('genql');\nconst model = require('./data/model.json');\n\nconst $ = new GenQL(model);\nconst fields = $._select();\nconst fieldPrefix = $._select('$');\nconsole.log(fields);\nconsole.log(fieldPrefix);\n\n// OUTPUT -\u003e {{fields}}\n// [\n//  'id',\n//  'name',\n//  'email',\n//  'COALESCE(NULLIF(class, ''), cls)',\n//  'status'\n// ]\n\n// OUTPUT -\u003e {{fieldPrefix}}\n// [\n//  '$.id',\n//  '$.name',\n//  '$.email',\n//  'COALESCE(NULLIF($.class, ''), cls)',\n//  '$.status'\n// ]\n\n```\n\n## API\n\n- **`_default(field)`**\n  - Returns default value for the field from model\n  - ***`Params`***\n    - field (string)\n\n- **`_insert(prefix)`**\n  - Returns all the fields from model, except the `auto` fields. Uses optional `prefix` and appends it to column name\n  - ***`Params`***\n    - prefix (String) {Optional}\n\n- **`_join(prefix)`**\n  - Returns all the fields from model, appended with `join_key` as prefix which is defined in model. Uses optional `prefix`  and appends it to column name\n  - ***`Params`***\n    - prefix (String) {Optional}\n\n- **`_findPrivate(prefix)`**\n  - Returns all the column which have `private` flag defined with it in the model. Uses optinal `prefix` and appends it to column names\n  - ***`Params`***\n    - prefix (String) {Optional}\n\n- **`_removePrivate(data)`**\n  - Removes all the values from `data` object which are marked as private column in model\n  - ***`Params`***\n    - data {JSON}\n\n- **`_values(data)`**\n  - Returns list of values from data object for all the columns from model which are not marked as private\n  - ***`Params`***\n    - data (JSON)\n\n- **`_select(prefix)`**\n  - Returns all the fields from model and uses alternate column if defined in model. Uses optional `prefix` and appends it to column name\n  - ***`Params`***\n    - prefix (String) {Optional}\n\n- **`_update(fields, data)`**\n  - Returns list of values from data for the input fields\n  - ***`Params`***\n    - fields (Array)\n    - data (JSON)\n\n\u003e Note: Sample model definition is available in [data/model.json](data/model.json)\n\n\n## Contributing\n\nInterested in contributing to this project?\nYou can log any issues or suggestion related to this library [here](https://github.com/arshadkazmi42/genql/issues/new)\n\nRead our contributing [guide](CONTRIBUTING.md) on getting started with contributing to the codebase\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farshadkazmi42%2Fgenql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farshadkazmi42%2Fgenql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farshadkazmi42%2Fgenql/lists"}