Schema
Schema Setting
Configuration file
The default configuration outputs zodSchema as follows.
format
Specifies the format of the schema name.
- camel - camel case (default)
- pascal - pascal case
- snake - snake case
- original - Use the original table name as it is
prefix
A string to be prepended to the type name. (Default is an empty string)
suffix
A string to be given after the type name. (Default is an empty string)
replacements
Performs type name substitution.
Specify the string before and after the substitution in string[][]
format. (Multiple specifications are allowed.) (Default is an empty array.)
nullType
Specifies what type to use for columns that are not NOT NULL
in MySQL.
- nullish - Use types that allow
null | undefined
(default) - nullable - Use types that allow
null
.
inline
Specifies whether schema should be defined inline. (Default is true
)
If inline
is set to false
, the schema is output to a separate file.
Below is an example of output to a separate file.
By outputting to a separate file, it is possible, for example, to convert a DATE type to a string type, or to specify your own zodSchema, which may be useful if you want to do things like refine.
zod
Specifies the schema implementation, valid only if inline is true.
- implementation - Specifies the implementation of schema. Specify the zodSchema to implement in
string[][]
format. (Default is an empty array.) Specify in the format of [MySQLTYPE, zodSchema].
If [[“DATE”, “z.string()”]] is specified for implementation, what would be z.date() becomes z.string().
- references - Specifies a reference to a schema. Specify the zodSchema to be referenced in
string[][]
format. (Default is an empty array.) Valid only if `inline’ is false.
If [[“DATE”, “superMyDate”]] is specified in references, the output will be as follows.
conversion Procedure of schema name
Schema name conversion is the same as for Type; see the Type conversion procedure.
conclusion
When you want to use your own implemented type, you can use reference or implementation to perform the conversion.