build
build<
TMap
,TCollection
>(config
):Effect
<void
,LoadingError
|TransformationError
|ValidationError
|ContentStoreError
,ContentStore
| { [K in string | number | symbol]: CollectionParts<TCollection[K]>[“loaderDeps”] | CollectionParts<TCollection[K]>[“transformerDeps”] | CollectionParts<TCollection[K]>[“validatorDeps”] }[keyofTCollection
]>
Defined in: packages/core/src/cms.ts:487
Builds and initializes all collections in the CMS. This function loads, transforms, validates, and stores all collection data.
Type Parameters
Section titled “Type Parameters”TMap
extends Record
<string
, CollectionAny
>
Record mapping collection names to their Collection definitions
TCollection
Section titled “TCollection”TCollection
extends Record
<string
, CollectionAny
> = TMap
The collection map type
Parameters
Section titled “Parameters”config
Section titled “config”Configuration object containing the collections to build
collections
Section titled “collections”TCollection
Returns
Section titled “Returns”Effect
<void
, LoadingError
| TransformationError
| ValidationError
| ContentStoreError
, ContentStore
| { [K in string | number | symbol]: CollectionParts<TCollection[K]>[“loaderDeps”] | CollectionParts<TCollection[K]>[“transformerDeps”] | CollectionParts<TCollection[K]>[“validatorDeps”] }[keyof TCollection
]>
Effect that completes when all collections have been built
Example
Section titled “Example”const buildEffect = build({ collections: { posts: postsCollection, users: usersCollection }});
yield* buildEffect;