{"id":25219673,"url":"https://github.com/fernandocode/database-builder","last_synced_at":"2025-08-01T23:44:09.411Z","repository":{"id":24403110,"uuid":"101402578","full_name":"fernandocode/database-builder","owner":"fernandocode","description":"Framework to assist in database manipulation (DDL and CRUD)","archived":false,"fork":false,"pushed_at":"2023-03-13T20:39:10.000Z","size":990,"stargazers_count":3,"open_issues_count":5,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-06T02:48:38.415Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/database-builder","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/fernandocode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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,"zenodo":null}},"created_at":"2017-08-25T12:39:59.000Z","updated_at":"2024-10-10T18:45:03.000Z","dependencies_parsed_at":"2025-07-06T02:40:39.111Z","dependency_job_id":"789d665c-7485-49f4-a050-88cb08187276","html_url":"https://github.com/fernandocode/database-builder","commit_stats":null,"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"purl":"pkg:github/fernandocode/database-builder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernandocode%2Fdatabase-builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernandocode%2Fdatabase-builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernandocode%2Fdatabase-builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernandocode%2Fdatabase-builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fernandocode","download_url":"https://codeload.github.com/fernandocode/database-builder/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernandocode%2Fdatabase-builder/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268314687,"owners_count":24231031,"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","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2025-02-10T21:09:19.494Z","updated_at":"2025-08-01T23:44:09.368Z","avatar_url":"https://github.com/fernandocode.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm version](https://badge.fury.io/js/database-builder.svg/?a=1)](https://www.npmjs.com/package/database-builder)\n[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/fernandocode/database-builder/issues)\n\n# database-builder\nLibrary to assist in creating and maintaining SQL commands.\n\n[look at the test for more details of use (`./src/test/`)](https://github.com/fernandocode/database-builder/tree/master/src/test)\n\n# Getting Started\n\n### Step 1: Install npm module\n\n```bash\nnpm install --save database-builder \n```\nThis will install the current stable version of `database-builder` in your `node_modules` directory and save the entry in `package.json`.\n\n### Step 2: Usage Typescript\n\n[*Demo*](https://stackblitz.com/edit/typescript-cfzt6q)\n\n```ts\nimport { Query } from 'database-builder';\nimport { TestClazz, TestClazzRef } from './models';\n\nlet querySimple = new Query(TestClazz);\nconsole.log(querySimple.compile());\n/**\n * {\n *  params: [],\n *  query: \"SELECT tes.* FROM TestClazz AS tes\"\n * }\n */\n\nconst queryWhere = new Query(TestClazz);\nqueryWhere.where(where =\u003e {\n  where.contains(x =\u003e x.description, \"abc\");\n  where.greatValue(x =\u003e x.id, 1);\n});\nconsole.log(queryWhere.compile());\n/**\n * {\n *  params: [\"%abc%\", 1],\n *  query: \"SELECT tes.* FROM TestClazz AS tes WHERE tes.description LIKE ? AND tes.id \u003e ?\"\n * }\n */\n\nconst queryProjections = new Query(TestClazz);\nqueryProjections.projection(projection =\u003e {\n  projection.add(x =\u003e x.description);\n  projection.sum(x =\u003e x.id);\n  projection.max(x =\u003e x.referenceTest.id);\n  projection.count(x =\u003e x.id, \"countId\");\n});\nconsole.log(queryProjections.compile());\n/**\n * {\n *  params: [],\n *  query: \"SELECT tes.description AS description, SUM(tes.id) AS id, MAX(tes.referenceTest_id) AS referenceTest_id, COUNT(tes.id) AS countId FROM TestClazz AS tes\"\n * }\n */\n\nconst queryOrderBy = new Query(TestClazz);\nqueryOrderBy.orderBy(x =\u003e x.id);\nconsole.log(queryOrderBy.compile());\n/**\n * {\n *  params: [],\n *  query: \"SELECT tes.* FROM TestClazz AS tes ORDER BY tes.id ASC\"\n * }\n */\n\nconst queryGroupBy = new Query(TestClazz);\nqueryGroupBy.groupBy(x =\u003e x.id, (having, projection) =\u003e {\n    having.greatValue(projection.count(x =\u003e x.id), 10);\n  });\nconsole.log(queryGroupBy.compile());\n/**\n * {\n *  params: [10],\n *  query: \"SELECT tes.* FROM TestClazz AS tes GROUP BY tes.id HAVING COUNT(tes.id) \u003e ?\"\n * }\n */\n\nconst queryLimitOffset = new Query(TestClazz);\nqueryLimitOffset.limit(10, 5);\nconsole.log(queryLimitOffset.compile());\n/**\n * {\n *  params: [10, 5],\n *  query: \"SELECT tes.* FROM TestClazz AS tes LIMIT ? OFFSET ?\"\n * }\n */\n```\n\nmodels.ts\n\n```ts\nexport class TestClazz {\n\n    public description: string = \"\";\n    public referenceTest: TestClazzRef = new TestClazzRef();\n    public disabled: boolean = false;\n}\n\nexport class TestClazzRef{\n\n    public id: number = 0;\n    public description: string = \"\";\n}\n```\n\n### Usage Angular 2+\n\n[*Demo*](https://stackblitz.com/edit/angular-vxnvua)\n\n```ts\nimport { Component } from '@angular/core';\nimport { Query } from 'database-builder';\nimport { TestClazz } from './models';\n\n@Component({\n    selector: 'app-component',\n    templateUrl: 'app.html'\n})\nexport class AppComponent {\n    \n    ngOnInit(){\n        let query = new Query(TestClazz);\n        query.where(where =\u003e where.between(x =\u003e x.id, 1, 20));\n        const result = query.compile();\n        console.log(result);\n        /**\n         * result:\n         * {\n         *  params: [1,20],\n         *  query: \"SELECT tes.* FROM TestClazz AS tes WHERE tes.id BETWEEN ? AND ?\"\n         * }\n         */\n    }\n}\n```\n\n### Usage Ionic 2+\n\n[\u003cdel\u003e*Demo*\u003c/del\u003e](https://stackblitz.com/edit/ionic-6sdjng)\n\nFor Ionic 2+ use [**ionic-database-builder**](https://github.com/fernandocode/ionic-database-builder).\n\n\u003e[`npm install --save ionic-database-builder`](https://www.npmjs.com/package/ionic-database-builder)\n\n\n# Contribution Welcome!\n\nThe project is continously evolving with every new release. Give it a star, if you like it. For contribution, setup the development environment as follows:\n\n1. clone and setup the project dependencies\n```shell\n$\u003e git clone https://github.com/fernandocode/database-builder.git\n$\u003e npm install\n```\n\n2. Use following commands based on what you'd like to do:\n\n```shell\n$\u003e npm run test              # runs test suite once and exit.\n```\n\n3. Have you found a bug, or want to develop a new feature?\n\n  3.1. [Look for Pull Requests](https://github.com/fernandocode/database-builder/pulls) if something is not already implemented;\n\n  3.2. [Check if there is no Issue related to this](https://github.com/fernandocode/database-builder/issues)? (If there is not one, so that the use case can be checked);\n\n  3.3. Make the necessary changes, add tests to what has been implemented, run the tests and submit a Pull Request with the changes (Comment what was done, and relate the Issue). As soon as possible it will be verified, and if approved it will be available in the next release of the library.\n\nIf you face any problem, then raise an issue [here](https://github.com/fernandocode/database-builder/issues).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffernandocode%2Fdatabase-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffernandocode%2Fdatabase-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffernandocode%2Fdatabase-builder/lists"}