joi-sql
Point it at your local database, and it spits out a Joi object validator.
Install
npm install joi-sql
(npm install -g joi-sql
if you want to use it from the command-line)
The only "breaking" change from 1.x to 2.x is that support for versions of node older than 8 was dropped.
Usage
CLI
joi-sql --host=localhost --user=root --password=abc123 --schema=awesomedb --table=customer --camel
host
, user
, password
, and camel
are all optional. schema
and table
are not.
If camel
is set, then column names are converted to camel case identifiers.
Spits out something like:
Joiobject projectId: Joi contactId: Joi dateCreated: Joi engineerId: Joi name: Joi engineeringProject: Joi printingProject: Joi activeProjectStateId: Joi startDate: Joi done: Joi doneDate: Joi deadReason: Joi quotedEngineeringHours: Joi actualEngineeringHours: Joi engineeringDueDate: Joi printParts: Joi printQuantity: Joi printTimeHours: Joi printDueDate: Joi paymentReceived: Joi contactDate: Joi replyDate: Joi quoteDate: Joi followUpDate: Joi notes: Joi version: Joi
Programmatic
Returns a promise that resolves to a string containing the code snippet above.
const joiSql =
You may also pass in an optional connection
property which must be a mysql
connection instance.
Pull requests welcome.