defineCollection
defineCollection<
TFieldMeta,TCollectionMeta,TCollectionSlug,TFields,TComponent,TDrafts,TTimestamps>(config):CollectionConfig<TFieldMeta&object,TCollectionMeta,TCollectionSlug,TFields,TComponent,TDrafts,TTimestamps,CollectionDataFieldSlug<TFields,TTimestamps>>
Defined in: packages/core/src/collections/config.ts:89
Resolves a raw collection config input into a fully-populated CollectionConfig.
Fills in any missing labels by deriving them from the slug — singularizing
then title-casing it for singular, and title-casing the slug itself for
plural (slugs are plural by convention).
Type Parameters
Section titled “Type Parameters”TFieldMeta
Section titled “TFieldMeta”TFieldMeta extends object = { }
TCollectionMeta
Section titled “TCollectionMeta”TCollectionMeta extends object = { }
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
TDrafts
Section titled “TDrafts”TDrafts extends boolean = false
TTimestamps
Section titled “TTimestamps”TTimestamps extends boolean = true
Parameters
Section titled “Parameters”config
Section titled “config”string extends keyof TFields ? CollectionConfigInput<TFieldMeta, TCollectionMeta, TCollectionSlug, TFields, TComponent, TDrafts, TTimestamps> : [keyof TFields & "vex_status" | "vex_publishedAt" | "vex_publishedId" | "vex_activeVersion" | "updatedAt"] extends [never] ? CollectionConfigInput<TFieldMeta, TCollectionMeta, TCollectionSlug, TFields, TComponent, TDrafts, TTimestamps> : object
The raw collection configuration supplied by the caller.
Returns
Section titled “Returns”CollectionConfig<TFieldMeta & object, TCollectionMeta, TCollectionSlug, TFields, TComponent, TDrafts, TTimestamps, CollectionDataFieldSlug<TFields, TTimestamps>>
The resolved CollectionConfig with all defaults applied.
Example
Section titled “Example”defineCollection({ slug: "posts", fields: { title: text({ required: true }), },});// → { slug: "posts", admin: { useAsTitle: "_id" }, labels: { singular: "Post", plural: "Posts" }, fields: { ... } }- CollectionConfigInput for the user-facing input type
- CollectionConfig for the resolved return type