defineCollection
defineCollection<
TFieldMeta,TCollectionMeta,TCollectionSlug,TFieldSlug,TComponent>(config):CollectionConfig<TFieldMeta&object,TCollectionMeta,TCollectionSlug,TFieldSlug,TComponent>
Defined in: packages/core/src/collections/config.ts:65
Resolves a raw collection config input into a fully-populated CollectionConfig.
Fills in any missing labels by deriving them from the slug — converting it
to title case for singular and further pluralising it for plural.
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
TFieldSlug
Section titled “TFieldSlug”TFieldSlug extends string = string
TComponent
Section titled “TComponent”TComponent extends ComponentHKT = ComponentHKT
Parameters
Section titled “Parameters”config
Section titled “config”CollectionConfigInput<TFieldMeta, TCollectionMeta, TCollectionSlug, TFieldSlug, TComponent>
The raw collection configuration supplied by the caller.
Returns
Section titled “Returns”CollectionConfig<TFieldMeta & object, TCollectionMeta, TCollectionSlug, TFieldSlug, TComponent>
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