defineMediaCollection
defineMediaCollection<
TFieldMeta,TCollectionMeta,TCollectionSlug,TFields,TComponent>(config):MediaCollectionConfig<TFieldMeta,TCollectionMeta,TCollectionSlug,TFields,TComponent>
Defined in: packages/file-storage-convex/src/mediaCollection.ts:49
Resolves a raw media collection config input into a fully-populated
MediaCollectionConfig tagged meta.storageAdapter: "convex".
Injects the Convex-specific base fields (filename, alt, mimeType,
size, storageId, deleted, src, width, height) beneath the
caller’s own fields and defaults admin.useAsTitle to filename. Pure
and client-safe — never touches the Convex SDK — so the result is declared
on the client config’s mediaCollections.
Type Parameters
Section titled “Type Parameters”TFieldMeta
Section titled “TFieldMeta”TFieldMeta extends BaseFieldMeta = BaseFieldMeta
TCollectionMeta
Section titled “TCollectionMeta”TCollectionMeta extends MediaCollectionMeta = MediaCollectionMeta
TCollectionSlug
Section titled “TCollectionSlug”TCollectionSlug extends string = string
TFields
Section titled “TFields”TFields extends Record<string, AdminField<TFieldMeta>> = Record<string, AdminField<TFieldMeta>>
TComponent
Section titled “TComponent”TComponent extends ComponentHKT = ComponentHKT
Parameters
Section titled “Parameters”config
Section titled “config”MediaCollectionConfigInput<TFieldMeta, TCollectionMeta, TCollectionSlug, TFields, TComponent> & object
The raw media collection configuration supplied by the caller.
Returns
Section titled “Returns”MediaCollectionConfig<TFieldMeta, TCollectionMeta, TCollectionSlug, TFields, TComponent>
The resolved MediaCollectionConfig with all defaults applied.
Example
Section titled “Example”import { defineMediaCollection } from "@vexcms/file-storage-convex/client";
const images = defineMediaCollection({ slug: "images", fields: { alt: text({ required: true }) },});
export default defineConfig({ mediaCollections: [images], collections: [posts],});- core/src!MediaCollectionConfigInput for the user-facing input type
- core/src!MediaCollectionConfig for the resolved return type