{"id":15659739,"url":"https://github.com/tehshrike/joi-sql","last_synced_at":"2025-05-05T03:26:07.224Z","repository":{"id":30932974,"uuid":"34490965","full_name":"TehShrike/joi-sql","owner":"TehShrike","description":"Create Joi validation code for MySQL databases","archived":false,"fork":false,"pushed_at":"2020-08-31T21:39:14.000Z","size":49,"stargazers_count":21,"open_issues_count":3,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-13T08:41:38.673Z","etag":null,"topics":["duck-typing","joi","mysql","sql"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"rdipietro/mist-rnns","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TehShrike.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":"2015-04-24T01:24:31.000Z","updated_at":"2022-08-08T08:51:13.000Z","dependencies_parsed_at":"2022-09-19T22:33:03.082Z","dependency_job_id":null,"html_url":"https://github.com/TehShrike/joi-sql","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TehShrike%2Fjoi-sql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TehShrike%2Fjoi-sql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TehShrike%2Fjoi-sql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TehShrike%2Fjoi-sql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TehShrike","download_url":"https://codeload.github.com/TehShrike/joi-sql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252431524,"owners_count":21746870,"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":["duck-typing","joi","mysql","sql"],"created_at":"2024-10-03T13:18:36.174Z","updated_at":"2025-05-05T03:26:07.187Z","avatar_url":"https://github.com/TehShrike.png","language":"JavaScript","readme":"# joi-sql\n\nPoint it at your local database, and it spits out a [Joi](https://github.com/hapijs/joi) object validator.\n\n[![Build Status](https://travis-ci.org/TehShrike/joi-sql.svg?branch=master)](https://travis-ci.org/TehShrike/joi-sql)\n\n## Install\n\n```sh\nnpm install joi-sql\n```\n\n(`npm install -g joi-sql` if you want to use it from the command-line)\n\nThe only \"breaking\" change from 1.x to 2.x is that support for versions of node older than 8 was dropped.\n\n## Usage\n\n### CLI\n\n```sh\njoi-sql --host=localhost --user=root --password=abc123 --schema=awesomedb --table=customer --camel\n```\n\n`host`, `user`, `password`, and `camel` are all optional.  `schema` and `table` are not.\n\nIf `camel` is set, then column names are converted to camel case identifiers.\n\nSpits out something like:\n\n```js\nJoi.object({\n\tprojectId: Joi.required().invalid(null).number().integer().max(4294967295).min(0),\n\tcontactId: Joi.required().invalid(null).number().integer().max(4294967295).min(0),\n\tdateCreated: Joi.required().invalid(null).date(),\n\tengineerId: Joi.number().integer().max(4294967295).min(0),\n\tname: Joi.required().invalid(null).string().allow('').max(200),\n\tengineeringProject: Joi.required().invalid(null).boolean(),\n\tprintingProject: Joi.required().invalid(null).boolean(),\n\tactiveProjectStateId: Joi.required().invalid(null).number().integer().max(4294967295).min(0),\n\tstartDate: Joi.date(),\n\tdone: Joi.required().invalid(null).boolean(),\n\tdoneDate: Joi.date(),\n\tdeadReason: Joi.string().allow('').max(65535),\n\tquotedEngineeringHours: Joi.number().precision(1).less(10000),\n\tactualEngineeringHours: Joi.number().precision(1).less(10000),\n\tengineeringDueDate: Joi.date(),\n\tprintParts: Joi.string().allow('').max(65535),\n\tprintQuantity: Joi.number().integer().max(8388607).min(-8388608),\n\tprintTimeHours: Joi.number().precision(1).less(10000),\n\tprintDueDate: Joi.date(),\n\tpaymentReceived: Joi.required().invalid(null).boolean(),\n\tcontactDate: Joi.date(),\n\treplyDate: Joi.date(),\n\tquoteDate: Joi.date(),\n\tfollowUpDate: Joi.date(),\n\tnotes: Joi.string().allow('').max(65535),\n\tversion: Joi.required().invalid(null).number().integer().max(4294967295).min(0)\n})\n```\n\n### Programmatic\n\nReturns a promise that resolves to a string containing the code snippet above.\n\n```js\nconst joiSql = require('joi-sql')\n\njoiSql({\n    host: 'localhost',\n    user: 'root',\n    password: 'abc123',\n    schema: 'awesomedb',\n    table: 'customer',\n    camel: true\n}).then(result =\u003e {\n\ttypeof result // =\u003e 'string'\n})\n```\n\nYou may also pass in an optional `connection` property which must be a [`mysql`](https://github.com/mysqljs/mysql) connection instance.\n\nPull requests welcome.\n\n## License\n\n[WTFPL](http://wtfpl2.com/)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftehshrike%2Fjoi-sql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftehshrike%2Fjoi-sql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftehshrike%2Fjoi-sql/lists"}