Creating SQL Domain
How to introduce a new SQL Domain
Section titled “How to introduce a new SQL Domain”A new SQL Domain can be introduced several ways:
- Direct Zod mapping when there’s a 1:1 mapping between a
ZodTypeand aSqlDomain(likez.string()orz.bigint()). - Using
zodSqlDomainRawCreateParamsto carry instructions in a Zoddescriptionproperty when theZodTypeneeds minor enhancements forSqlDomain(like when az.date()should provide additional meta data for patterns or defaults or constraints). - Using
ZodTypedBaggageandzodBaggagewhere more customizations are required (such as a primary key column or foreign key column with constraints or other more advanced use cases).
Direct Zod mapping
Section titled “Direct Zod mapping”If your new Zod type is a simple 1:1 mapping to SQL Domain (like z.string() or
z.bigint()), in render/domain/domain.ts see SqlDomain interface and then
determine if your new domain meets one of the following factory patterns:
zodStringSqlDomainFactoryzodJsonSqlDomainFactoryzodNumberSqlDomainFactoryzodDateSqlDomainFactoryzodEnumSqlDomainFactory
If your new domain falls into the above categories, you should add a new case statement in the appropriate factory. If your new Zod type is unrelated to any of the existing categories, create a category factory.
After adding your new type’s case statement to the above factory switches, call
the factory method in zodTypeSqlDomainFactory.
Using zodSqlDomainRawCreateParams
Section titled “Using zodSqlDomainRawCreateParams”TODO
Using ZodTypedBaggage and zodBaggage
Section titled “Using ZodTypedBaggage and zodBaggage”TODO