Skip to content

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.

TFieldMeta extends object = { }

TCollectionMeta extends object = { }

TCollectionSlug extends string = string

TFieldSlug extends string = string

TComponent extends ComponentHKT = ComponentHKT

CollectionConfigInput<TFieldMeta, TCollectionMeta, TCollectionSlug, TFieldSlug, TComponent>

The raw collection configuration supplied by the caller.

CollectionConfig<TFieldMeta & object, TCollectionMeta, TCollectionSlug, TFieldSlug, TComponent>

The resolved CollectionConfig with all defaults applied.

defineCollection({
slug: "posts",
fields: {
title: text({ required: true }),
},
});
// → { slug: "posts", admin: { useAsTitle: "_id" }, labels: { singular: "Post", plural: "Posts" }, fields: { ... } }