Shared types in Schema
Hello, is it possible to create some sort of shared type (something like interface from TS) for Convex schema? I have the same fields in table schema and in the mutation params but it still different from Doc<...>, so I was wondering if I can somehow combine them into 1 generic type and share between mutation and DB schema. Otherwise right now I need to change types in both places.
2 Replies
Two great articles for ya:
https://stack.convex.dev/types-cookbook
https://stack.convex.dev/argument-validation-without-repetition
Types and Validators in TypeScript: A Convex Cookbook
It can be tough to wrangle types to behave how you want them to. Thankfully, Convex was designed to make the experience with types perfect. Learn why ...
Argument Validation without Repetition
In the first post in this series, the Types and Validators cookbook,, we shared several basic patterns & best practices for reusing types & validators...
Thank you!