collectionConfigToInterface
collectionConfigToInterface(
props):string
Defined in: packages/core/src/collections/interfaceGen.ts:31
Converts a resolved CollectionConfig to a TypeScript export interface source string.
Each generated interface extends VexDocument (inheriting _id and _creationTime)
and overrides _id with the branded Convex Id<"slug"> type for that collection.
Optional fields (field.required === false) are emitted with the ? modifier.
select fields with custom options emit a companion type alias above the interface,
named <InterfaceName><FieldKey>Option so the same field key on two collections does
not produce two aliases with one name. Override with the field’s optionInterfaceName.
Parameters
Section titled “Parameters”Input props.
collection
Section titled “collection”The resolved collection definition to convert.
Returns
Section titled “Returns”string
A TypeScript source string for one document interface block.
Example
Section titled “Example”const collection = defineCollection({ slug: "posts", fields: { title: text({ required: true }), excerpt: text({ required: false }) },});collectionConfigToInterface({ collection });// → 'export interface PostsDocument extends VexDocument {\n\t_id: Id<"posts">\n\ttitle: string\n\texcerpt?: string\n}'generateVexTypes for the full-file generator that wraps this function