Trpc & non-consistent JSON Field Attributes in MySQL

Just getting used to trpc & the t3 stack. Say I have a standard procedure:
update: t.procedure
.input(z.object({
id: z.string(),
type: z.string(),
content: z.object({ title: z.string() }).nullish()
}).nullish())
update: t.procedure
.input(z.object({
id: z.string(),
type: z.string(),
content: z.object({ title: z.string() }).nullish()
}).nullish())
Now what I am interested in is the content attribute. In my mysql schema, that content field is a JSON field. Depending on the type field, it will contain different values. For example. If type is blogPost, it will contain attributes like title & category, but if the type is set to landingPage those attributes will change. (just an example to make it more straightforward, my use case isn't about blogPosts etc.) Now trpc expects me to tell it what the object looks like: e.g.: there is a title, which is a string. But what if my landingPage type looks totally different, and, say, doesn't have a title?
1 Reply
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server