#Types and Validators in TypeScript: A Convex Cookbook

9 messages · Page 1 of 1 (latest)

vernal oracle
shut galleon
#

I'm curious, is there any difference in using Infer on the validator, or using the .type directly from the validator?

Infer

export type Challenge = Infer<typeof challengeValidator>

.type

export type Challenge = typeof challengeValidator.type
weak geode
shut galleon
weak geode
mortal glacier
#

Yeah I think ['type'] is technically internal

shut galleon
#

Good point. Also prefer the Infer syntax.

compact bear
#

Nice article. I wonder if there is scope for doing an article that talks about evolving your schema over time, techniques and methods for it.

#

For me that’s one of the biggest strengths of convex DB flexible schema that you can use union and literal to extend a table in the future should you want to store different “kinds” of things in it later on