Introduction
What is mysql-to-zod?
mysql-to-zod is a tool that generates Zod type definitions from MySQL table definitions.
Usage
The above command will generate Zod-specific type definitions of all tables in “dbname”, saving the new TypeScript code in ./mysqlToZod/schema.ts
.
Example
Suppose DB: my_todo has the following table definitions.
From the above table definition, the following Zod schema is generated.
Summary
These are the basic instructions for use. In many cases the above is all that is needed.
But with extensive options many details can be customized.
For example, you may want the variable name to be TODO_SCHEMA
instead of todoSchema
.
Please visit Discussions for all questions about usage, and suggestions for improvement.