DiamondDragonD
Convex Community14mo ago
5 replies
DiamondDragon

Zod Unions appear to break `Table` helper (maybe zodToConvex related?)

https://stack.convex.dev/convex-the-database-that-made-me-switch-careers

I'm following the pattern described in this article and getting an type error here. Looks to be since the Table expects a Record while the union produces an array of members.

This still works below so i'll do this, but wanted to flag this in case it wasn't known

export const TestTable = Table('test', convexTestSchema.members) will same type error

export default defineSchema({
    test: defineTable(convexTestSchema),
})


The problem Im trying to solve is dynamic data for a data table where each field/column type can only support specific value types (like a short text field can only support z.string()`. I'm writing all of these combinations as unions and merging the rest of the base table fields in each union member.

Seems like teh best way of going about this so its impossibel to accidentally pass in a string value for a boolean field
image.png
Today is my first day working for Convex 🎉, so I thought I’d take the opportunity to share my thoughts on why I decided to join and what excites me a...
Convex: The Database that Made Me Switch Careers
Was this page helpful?