Creating SQL Domain
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
ZodType
and aSqlDomain
(likez.string()
orz.bigint()
). - Using
zodSqlDomainRawCreateParams
to carry instructions in a Zoddescription
property when theZodType
needs minor enhancements forSqlDomain
(like when az.date()
should provide additional meta data for patterns or defaults or constraints). - Using
ZodTypedBaggage
andzodBaggage
where 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
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:
zodStringSqlDomainFactory
zodJsonSqlDomainFactory
zodNumberSqlDomainFactory
zodDateSqlDomainFactory
zodEnumSqlDomainFactory
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
TODO
Using ZodTypedBaggage
and zodBaggage
TODO