{"id":26075892,"url":"https://github.com/uchennaemeruche/mysql-util","last_synced_at":"2026-05-04T09:31:55.637Z","repository":{"id":57306884,"uuid":"299077977","full_name":"uchennaemeruche/mysql-util","owner":"uchennaemeruche","description":"Utility module for mysql and nodejs","archived":false,"fork":false,"pushed_at":"2022-11-10T03:40:04.000Z","size":414,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-05T05:39:57.610Z","etag":null,"topics":["database","mysql","nodejs"],"latest_commit_sha":null,"homepage":"","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/uchennaemeruche.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}},"created_at":"2020-09-27T16:58:19.000Z","updated_at":"2024-03-25T03:19:09.000Z","dependencies_parsed_at":"2023-01-21T09:16:30.405Z","dependency_job_id":null,"html_url":"https://github.com/uchennaemeruche/mysql-util","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/uchennaemeruche/mysql-util","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uchennaemeruche%2Fmysql-util","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uchennaemeruche%2Fmysql-util/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uchennaemeruche%2Fmysql-util/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uchennaemeruche%2Fmysql-util/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uchennaemeruche","download_url":"https://codeload.github.com/uchennaemeruche/mysql-util/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uchennaemeruche%2Fmysql-util/sbom","scorecard":{"id":906644,"data":{"date":"2025-08-11","repo":{"name":"github.com/uchennaemeruche/mysql-util","commit":"961a054a708336f13f5b6ca23486ca8d296824dc"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/12 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/release.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Pinned-Dependencies","score":2,"reason":"dependency not pinned by hash detected -- score normalized to 2","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/uchennaemeruche/mysql-util/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/uchennaemeruche/mysql-util/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:46: update your workflow using https://app.stepsecurity.io/secureworkflow/uchennaemeruche/mysql-util/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:47: update your workflow using https://app.stepsecurity.io/secureworkflow/uchennaemeruche/mysql-util/release.yml/master?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/release.yml:54","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   2 out of   3 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"26 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-h5c3-5r3r-rr8q","Warn: Project is vulnerable to: GHSA-rmvr-2pp2-xj38","Warn: Project is vulnerable to: GHSA-xx4v-prfh-6cgc","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5","Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j","Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22","Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-mqr2-w7wj-jjgr","Warn: Project is vulnerable to: GHSA-49j4-86m8-q2jw","Warn: Project is vulnerable to: GHSA-fpw7-j2hg-69v5","Warn: Project is vulnerable to: GHSA-4rch-2fh8-94vw","Warn: Project is vulnerable to: GHSA-pmh2-wpjm-fj45","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-76p7-773f-r4q5","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-24T17:36:21.787Z","repository_id":57306884,"created_at":"2025-08-24T17:36:21.787Z","updated_at":"2025-08-24T17:36:21.787Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32601509,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T22:12:39.696Z","status":"online","status_checked_at":"2026-05-04T02:00:06.625Z","response_time":58,"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":["database","mysql","nodejs"],"created_at":"2025-03-09T01:29:08.020Z","updated_at":"2026-05-04T09:31:55.617Z","avatar_url":"https://github.com/uchennaemeruche.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mysql-query-util\n\n\u003c!-- [![Build Status](https://travis-ci.com/uchennaemeruche/mysql-util.svg?token=UzXstzQpgUvQ1wppiktz\u0026branch=master)](https://travis-ci.com/uchennaemeruche/mysql-util) --\u003e\n\n[![Build Status](https://github.com/uchennaemeruche/mysql-util/actions/workflows/release.yml/badge.svg?\u0026branch=master)](https://github.com/uchennaemeruche/mysql-util)\n\n[![NPM](https://img.shields.io/npm/l/mysql-query-util)](https://github.com/uchennaemeruche/mysql-util)\n[![npm](https://img.shields.io/npm/v/mysql-query-util)](https://npmjs.com/package/mysql-query-util)\n\n##### A simple and light-weight utility module for mysql and nodejs.\n\nThis plugin helps construct mysql queries with more relatable syntax just like most non-sql database management systems. It is a [NodeJs](https://nodejs.org/en) module available through the npm registry so be sure to [download and install NodeJS](https://nodejs.org/en/download) first.\n\n---\n\n## Installation\n\n```bash\nnpm install --save mysql-query-util\n```\n\n## Features\n\nThe plugin abstracts most redundant mysql CRUD queries from the developer by providing an easier and more declarative way of constructing queries for:\n\n- [Selecting](#Selecting)\n- [Insertion](#Insertion)\n- [Update](#Update)\n- [Delete](#Delete)\n\n### Configuration and usage\n\nHere is an example of how to use the plugin:\nNote: You can either pass positional args or an object to the methods.\n\n```js\nconst mysqlUtil = require(\"mysql-query-util\");\n\nmysqlUtil.setConnection({\n    host: process.env.DB_HOST, //database host, eg: localhost\n    user: process.env.DB_USER, // database user, eg: root\n    password: process.env.DB_PASSWORD, //database password,eg: anything\n    database: process.env.DB_NAME // database name, eg: anything,\n    connectionLimit: 25 // connection Limit(Integer)\n});\n\nconst queryResult = await mysqlUtil.select(tableName, fields, params|Optional);\nconst queryResult = await mysqlUtil.select({tableName:String, fields:[fieds|columns_to_select], params:[[params|optional]]});\n\neg: const result = await  mysqlUtil.select(\"users\");\neg: const result = await mysqlUtil.select({tableName:'users'});\n\n\n```\n\nThe above code first initializes a connection before making queries.The initialization happens only once as it creates a connection pool and returns an connection object to be used for subsequent queries.\n\nIn the second paragraph, since all the methods return a promise, we await for the promise or use the .then to get the result of the operation.\n\n### Selection query\n\nThe package exposes a **.select** method that runs a mysql select query. This method accepts three(3) positional arguments or an object -\n\n```js\n// Fetch all record from `users` table\nconst result = await mysqlUtil.select(\"users\");\n// OR\nconst result = await mysqlUtil.select({ tableName: \"users\" }).then((res) =\u003e {});\n\n// Fetch the name and age from the users table\nconst result = await mysqlUtil.select(\"users\", [\"name\", \"age\"]);\n// OR\nconst result = await mysql.select({\n  tableName: \"users\",\n  fields: [\"name\", \"age\"],\n});\n\n// Fetch all female users whose age is greater that 40\nconst result = await mysqlUtil.select(\"users\", \"*\", [\n  [\"gender\", \"like\", \"female\"],\n  [\"AND\", \"age\", \"\u003e\", 40],\n]);\n// OR\nconst result = await mysqlUtil.select({\n  tableName: \"users\",\n  fields: [\"name\", \"age\"],\n  params: [\n    [\"gender\", \"like\", \"female\"],\n    [\"OR\", \"age\", \"\u003e\", 40],\n  ],\n}); // To fetch the name and age of all female users that pass a given condition.\n```\n\n### Insert Query\n\nSimilary, there is a **.insert** method that runs a mysql insert query. This method accepts two(2) positional arguments or an object -\n\n```js\n// Insert into `users` table\nlet data = {\n  name: \"Foo Bar\",\n  gender: \"female\",\n  age: 28,\n};\nconst result = await mysqlUtil.insert(\"users\", data); // mysqlUtil.insert({tableName:\"users\", data}).then((res) =\u003e {});\n\n// OR\nconst result = await mysqlUtil.insert({ tableName: \"users\", data: data });\n```\n\n### Update Query\n\nTo run an update, use the **.update** method. This method accepts three arguments(The table, the new data, and the update condition).\n\n```js\n// Insert into `users` table\nlet newData = {\n  gender: \"male\",\n};\nlet updateCondition = [\n  [\"id\", \"=\", 55],\n  [\"AND\", \"age\", \"=\", 28],\n];\nconst result = await mysqlUtil.update(\"users\", newData, updateCondition);\n```\n\nOR\n\n```js\nconst result = await mysqlUtil.update({\n  tableName: \"users\",\n  data: newData,\n  params: updateCondition,\n});\n```\n\n### Delete Query\n\nThe **.delete** method accepts two arguments- The table name and the delete condition:\n\n```js\nlet params = [[\"id\", \"=\", 55]];\nconst result = mysqlUtil.delete(\"users\", params);\n```\n\nOR\n\n```js\nconst result = mysqlUtil.delete({ tableName: \"users\", params: params }); // mysqlUtil.delete({ tableName: \"users\", params });\n```\n\n### .query method\n\nThe package also exposes a generic **.query** method. See the [test folder on github](https://github.com/uchennaemeruche/mysql-util/tree/master/test) for examples(apis, test) on how to use this method and the ones listed above.\n\n### Handling Raw SQL query\n\nWith the **.rawQuery** method, raw sql queries can be executed. Also, this method can be used to call stored procedures.\n\n```js\nmysqlUtil\n  .rawQuery(\"CREATE DATABASE IF NOT EXISTS kings_restaurant\")\n  .then((result) =\u003e {\n    mysqlUtil.rawQuery(\n      \"CREATE TABLE IF NOT EXISTS customers(id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), address VARCHAR(255), phone VARCHAR(255))\"\n    );\n  });\n```\n\nOR\n\n```js\nconst result = await mysqlUtil.rawQuery(\"CREATE DATABASE IF NOT EXISTS testdb\");\n\nconst result = await mysqlUtil.rawQuery(\"select * from customers\");\n\nconst result = await mysqlUtil.rawQuery(\"call fetchCustomers\"); // Where fetchCustomers is the name of a stored procedure.\n```\n\nSee the [test folder on github](https://github.com/uchennaemeruche/mysql-util/blob/master/test/schema.test.js) for examples on how to use this method.\n\n### License\n\nThis project is licensed under the MIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuchennaemeruche%2Fmysql-util","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuchennaemeruche%2Fmysql-util","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuchennaemeruche%2Fmysql-util/lists"}