{"id":20671103,"url":"https://github.com/allnulled/sql-utils","last_synced_at":"2026-04-17T16:31:14.529Z","repository":{"id":57096712,"uuid":"254093675","full_name":"allnulled/sql-utils","owner":"allnulled","description":"Various SQL utilities for Node.js","archived":false,"fork":false,"pushed_at":"2020-04-09T11:22:30.000Z","size":113,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-22T23:26:44.068Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/allnulled.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-04-08T13:20:42.000Z","updated_at":"2020-04-09T11:22:33.000Z","dependencies_parsed_at":"2022-08-20T16:50:27.953Z","dependency_job_id":null,"html_url":"https://github.com/allnulled/sql-utils","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/allnulled/sql-utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allnulled%2Fsql-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allnulled%2Fsql-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allnulled%2Fsql-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allnulled%2Fsql-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/allnulled","download_url":"https://codeload.github.com/allnulled/sql-utils/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allnulled%2Fsql-utils/sbom","scorecard":{"id":185843,"data":{"date":"2025-08-11","repo":{"name":"github.com/allnulled/sql-utils","commit":"29e4662a910a3489edaa0f2f47eb89b7dc45d0de"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"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":"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":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Code-Review","score":0,"reason":"Found 0/7 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":"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":"Dangerous-Workflow","score":-1,"reason":"no workflows found","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":"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":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"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":"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":"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":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"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":"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":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"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"}}]},"last_synced_at":"2025-08-16T19:47:10.174Z","repository_id":57096712,"created_at":"2025-08-16T19:47:10.174Z","updated_at":"2025-08-16T19:47:10.174Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31936501,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-17T12:37:54.787Z","status":"ssl_error","status_checked_at":"2026-04-17T12:37:25.095Z","response_time":62,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":"2024-11-16T20:25:02.608Z","updated_at":"2026-04-17T16:31:14.463Z","avatar_url":"https://github.com/allnulled.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sql-utils\n\nVarious SQL utilities for Node.js\n\n## Installation\n\n`$ npm i -s @allnulled/sql-utils`\n\n## Usage\n\n```js\nconst SQLUtils = require(\"sql-utils\");\nconst whereSQL = SQLUtils.whereToSQL({\n\tname: \"somename\",\n\tpassword: \"somepassword\"\n});\nconst query = `SELECT * FROM user WHERE ${whereSQL}`;\n```\n\n### `whereToSQL` function\n\n`SQLUtils.whereToSQL(...)` allows to obtain SQL `WHERE` expressions from:\n\n   - `Object`: where each property is a column, and each value, a `SQL` (escaped) value.\n   - `Array`: where each item represents:\n       - *2 values*: SQL column and value, bound by `=`\n       - *3 values*: SQL column, SQL logic operators, and value\n   - `String`: inline `SQL` injections are allowed by the framework, to fully customize what is going on `WHERE` SQL expressions.\n\nThis function also allows you to use `in` and `not in` operators with `Arrays` of values (that will be safely escaped).\n\n## API\n\n------\n\n\n\n#### `const SQLUtils = require(\"sql-utils\")`\n\n\n\n**Type**:  Class\n\n\n**Description**:  Class that contains the whole API of the package.\n\n\n\n\n----\n\n#### `SQLUtils.die(...args:any)`\n\n\n\n**Type**:  Static method\n\n\n**Description**:  Prints by console whatever you pass, and kills the process.\n\n\n\n\n----\n\n#### `SQLUtils.getPropertiesSQL(property:String|Any, table:String|Boolean)`\n\n\n\n**Type**:  Static method\n\n\n**Parameter**: \n\n\n  - `property:String|Any`. SQL column name. When it is not a string, it is returned directly.\n\n\n  - `table:String|Boolean`. Optional. SQL table name. When it is a falsy value, it is omitted.\n\n\n**Return**:  `sql:String`. SQL code to represent this column.\n\n\n**Description**:  Splits the property by `\".\"`, escaped as SQL ids every part, and prefixes with the name of the table, if any.\n\n\n\n\n----\n\n#### `SQLUtils.generateToken(length:Integer, charset:Array)`\n\n\n\n**Type**:  Static method\n\n\n**Parameter**: \n\n\n  - `length:Integer`. Required. Number of characters for the token.\n\n\n  - `charset:Array\u003cString\u003e`. Optional. Valid characters for the token.\n\n\n**Return**:  `token:String`. Generated token.\n\n\n**Description**:  Returns a token from the pool of characters provided.\n\n\n\n\n----\n\n#### `SQLUtils.rowsToObject(rows:Array\u003cObject\u003e, table:String, columnId:String)`\n\n\n\n**Type**:  Static method\n\n\n**Parameter**: \n\n\n  - `rows:Array\u003cObject\u003e`. Required. Data in arrays of objects, where each object property is read like: `$table.$column`.\n\n\n  - `table:String`. Required. Table to extract the data from.\n\n\n  - `columnId:String`. Optional. Column to index all data rows by. By default: `\"id\"`.\n\n\n**Return**:  `formattedData:Array\u003cObject\u003e`. Data resulted from the operation.\n\n\n**Description**:  Returns an array of objects with the properties like `${table}.*` grouped by the rows that have the same `columnId`.\n\n\n\n\n----\n\n#### `SQLUtils.whereToSQL(where:Array|Object, table:String, andPrefix:Boolean, defaultValue:String)`\n\n\n\n**Type**:  Static method\n\n\n**Parameter**: \n\n\n  - `where:Object|Array`. Required. As object, it must contain the properties (columns) and the expected values. As array, it must contain arrays of 2 or 3 items: subject and object, or subject, operator and object respectively.\n\n\n  - `table:String`. Optional. Table used to prefix the properties in this `where` statement part. By default: `false`.\n\n\n  - `andPrefix:Boolean`. Optional. If `true`, a ` AND ` will prefix the generated code. By default: `false`.\n\n\n  - `defaultValue:String`. Required. Column to index all data rows by. By default: `\"1 = 1\"`.\n\n\n**Return**:  `sql:String`. SQL code that represents this partial `WHERE` statement.\n\n\n**Description**:  Returns SQL code to represent a specific `WHERE` statement part.\n\n\n\n\n\n------\n\n## License\n\nThis project is under [WTFPL](https://es.wikipedia.org/wiki/WTFPL), which means basically: *do What The Fuck you want with it*.\n\n## Contact\n\nPlease, address issues and suggestions [here](https://github.com/allnulled/sql-utils/issues). Thank you.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallnulled%2Fsql-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fallnulled%2Fsql-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallnulled%2Fsql-utils/lists"}