https://docs.convex.dev/database/schemas#unions
example from the docs
defineTable(
v.union(
v.object({
kind: v.literal("StringDocument"),
value: v.string(),
}),
v.object({
kind: v.literal("NumberDocument"),
value: v.number(),
})
)
);
in this example I wonder if value can be a v.object instead of v.string and v.number.
I also wonder if the kind field has to be always named kind or can it be also tag?
I'm exploring how to map this to Rescript Variants
I would like to do something like this
let jobWindow = {
width: v.number(),
height: v.number()
}
let jobProduct = {
qty: v.number(),
name: v.string()
}
defineTable({
v.union(
v.object({
tag: v.literal("JobWindow"),
value: jobWindow,
}),
v.object({
tag: v.literal("JobProduct"),
value: jobProduct,
})
)
});