How to discriminate queryCollection results? #3075
Unanswered
adrianrudnik
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
What would be the best way to discriminate between the results of multiple
queryCollection
calls?Basic usage for me is: I have many different kind of types of documents, like guides, workarounds, lists, notes, each one its own set of markdown files with only a single shared schema field:
code
which is unique per document, but the rest of the schema is different otherwise.Normally I would add a literal discriminator field to the union of types, but
z.literal()
does not seem to be supported for thedefineCollection
as it throws me aUnsupported Zod type: ZodLiteral
.So instead of simply determining the type prior going into details like
I now have to focus on each attribute like
Any other approach so far has led to the typescript service/validation screaming at me.
Beta Was this translation helpful? Give feedback.
All reactions