@datazod/zod-sql
Version:
Convert Zod schemas to SQL table definitions with support for SQLite, PostgreSQL, and MySQL
18 lines (17 loc) • 528 B
JavaScript
import { mapZodToMySQL } from './mysql';
import { mapZodToPostgres } from './postgres';
import { mapZodToSQLite } from './sqlite';
/**
* Maps a Zod type to its corresponding SQL data type based on the dialect
*/
export const mapZodToSql = (zodType, dialect = 'sqlite') => {
switch (dialect) {
case 'postgres':
return mapZodToPostgres(zodType);
case 'mysql':
return mapZodToMySQL(zodType);
case 'sqlite':
default:
return mapZodToSQLite(zodType);
}
};