Config
設定ファイルの置き場
mysql-to-zod
を実行する際、設定ファイルの場所を指定することができます。
npx mysql-to-zod mysql://user:password@localhost:3306/dbname -f ./mysqlToZod.config.js
指定がなかった場合は、実行されたディレクトリの直下にあるmysqlToZod.config.js
が読み込まれます。
設定ファイルの書き方
設定ファイルは以下のように記述します。
const options = { output: { outDir: "./mysqlToZod", fileName: "schema.ts", }, comments: { table: { active: true, format: "// [table:!name] : !text", }, column: { active: true, format: "// !name : !text", }, }, type: { declared: "type", format: "pascal", prefix: "", suffix: "", replacements: [], }, schema: { format: "camel", prefix: "", suffix: "Schema", replacements: [], nullType: "nullish", inline: true, zod: { implementation: [], references: [], }, }, sync: { active: true, },};module.exports = options;
設定ファイルはなくても良い
設定ファイルが存在しない場合、デフォルトの設定が適用されます。
各設定については次項以降を参照してください。