{"id":49242281,"url":"https://github.com/ashotsiroyan/sqltool","last_synced_at":"2026-04-24T20:05:37.099Z","repository":{"id":57368375,"uuid":"334926838","full_name":"ashotsiroyan/sqltool","owner":"ashotsiroyan","description":"MySQL object modeling tool","archived":false,"fork":false,"pushed_at":"2025-10-06T12:30:25.000Z","size":160,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-06T14:32:07.368Z","etag":null,"topics":["callbacks","mysql","object-modeling","promises"],"latest_commit_sha":null,"homepage":"","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/ashotsiroyan.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-01T11:25:34.000Z","updated_at":"2021-06-23T12:31:53.000Z","dependencies_parsed_at":"2022-09-05T19:20:13.901Z","dependency_job_id":null,"html_url":"https://github.com/ashotsiroyan/sqltool","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/ashotsiroyan/sqltool","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashotsiroyan%2Fsqltool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashotsiroyan%2Fsqltool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashotsiroyan%2Fsqltool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashotsiroyan%2Fsqltool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ashotsiroyan","download_url":"https://codeload.github.com/ashotsiroyan/sqltool/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashotsiroyan%2Fsqltool/sbom","scorecard":{"id":211869,"data":{"date":"2025-08-11","repo":{"name":"github.com/ashotsiroyan/sqltool","commit":"b6a6020685e08736eb6db3da72e6865e1d3bbc93"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 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":"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":"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":"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":"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":"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":"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":"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":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Info: FSF or OSI recognized license: MIT License: LICENSE.md:0"],"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-17T00:54:04.776Z","repository_id":57368375,"created_at":"2025-08-17T00:54:04.776Z","updated_at":"2025-08-17T00:54:04.776Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32238778,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T13:21:15.438Z","status":"ssl_error","status_checked_at":"2026-04-24T13:21:15.005Z","response_time":64,"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":["callbacks","mysql","object-modeling","promises"],"created_at":"2026-04-24T20:05:33.546Z","updated_at":"2026-04-24T20:05:37.085Z","avatar_url":"https://github.com/ashotsiroyan.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SQLtool\nSQLtool is a MySQL object modeling tool designed to work in an asynchronous environment. SQLtool supports both promises and callbacks.\n\n## Installation\n```\n$ npm install sqltool2\n```\n\n## Importing\n```js\n// Using Node.js `require()`\nconst sqltool = require('sqltool2');\n\n// Using ES6 imports\nimport sqltool from 'sqltool2';\n```\n\n## Overview\n\n### Connecting to MySQL\n```js\nawait sqltool.connect({\n    host: 'localhost',\n    user: 'root',\n    password: '',\n    database: 'db_name'\n});\n```\n\nOnce connected, the `open` event is fired on the `Connection` instance. If you're using `sqltool.connect`, the `Connection` is `sqltool.connection`. Otherwise, `sqltool.createConnection` return value is a `Connection`.\n\n**Important!** SQLtool buffers all the commands until it's connected to the database. This means that you don't have to wait until it connects to MySQL in order to define models.\n\n### Defining a Model\nModels are defined through the Schema interface.\n\n```js\nconst Schema = sqltool.Schema;\n\nconst BlogPost = new Schema({\n  author: 'VARCHAR',\n  title: 'VARCHAR',\n  body: 'TEXT',\n  date: 'DATE'\n});\n```\nThe following example with some features.\n\n```js\nconst Comment = new Schema({\n  name: { type: 'VARCHAR', size: 32, default: 'hahaha' },\n  age: { type: 'INT', unsigned: true },\n  bio: { type: 'VARCHAR' },\n  date: { type: 'DATE', default: new Date() }\n});\n\n// create index\nComment.index({name: 'text', bio: 'text'});\n\n// middleware\nComment.pre('save', function (next) {\n  console.log(this.name);\n  next();\n});\n```\n\n**Important!** We define table structure through model and table is created automatically.\n\n### Accessing a Model\nOnce we define a model through `sqltool.model('ModelName', mySchema)`, we can access it through the same function\n\n```js\nconst MyModel = sqltool.model('ModelName');\n```\n\nOr just do it all at once\n```js\nconst MyModel = sqltool.model('ModelName', mySchema);\n```\n\nThe first argument is the singular name of the table your model is for. \n\nOnce we have our model, we can then instantiate it, and save it:\n```js\nconst instance = MyModel.new();\ninstance.name = 'karen';\ninstance.save(function (err) {\n  //\n});\n```\n\nor\n\n```js\nconst instance = MyModel.new({ name: 'karen' });\ninstance.save(function (err) {\n  //\n});\n```\n\nWe can find documents from the same table\n```js\n// find all documents\nMyModel.find({ }).exec(function (err, docs) {\n  // docs.forEach\n});\n\n// find all documents named karen and at least 19\nawait MyModel.find({ name: 'karen', age: { $gte: 19 } }).exec();\n\n// executes, passing results to callback\nMyModel.find({ name: 'karen', age: { $gte: 19 } }).exec(function (err, docs) {\n  // docs.forEach\n});\n\n// executes, name LIKE karen and only selecting the \"name\" and \"age\" fields\nawait MyModel.find({ name: { $in: 'karen' } }, ['name', 'age']).exec();\n\n// find 3 documents and sort name in DESC order\nawait MyModel.find({ }).limit(3).sort({ name: -1 }).exec();\n\n// find 3 documents skipping 4\nawait MyModel.find({ }).limit(3).skip(4).exec();\n```\n\nYou can also `findOne`, `findById`, `updateOne`, etc.\n```js\nconst instance = await MyModel.findOne({ ... }).exec();\nconsole.log(instance.name);  // 'karen'\n```\n\n**Important!** If you opened a separate connection using `sqltool.createConnection()` but attempt to access the model through `sqltool.model('ModelName')` it will not work as expected since it is not hooked up to an active db connection. In this case access your model through the connection you created:\n```js\nconst conn = await sqltool.createConnection({ conn_params });\nconst MyModel = conn.model('ModelName', schema);\nconst m = MyModel.new();\nm.save(); // works\n```\n\nvs\n\n```js\nconst conn = await sqltool.createConnection({ conn_params });\nconst MyModel = sqltool.model('ModelName', schema);\nconst m = MyModel.new();\nm.save(); // does not work b/c the default connection object was never connected\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashotsiroyan%2Fsqltool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fashotsiroyan%2Fsqltool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashotsiroyan%2Fsqltool/lists"}