DepthPopulate
DepthPopulate<
TCollectionSlug,D,_Counter> =_Counter["length"] extendsD?Record<string,never> : [..._Counter,0]["length"] extendsD?{ [K in RelationshipKeysOf<TCollectionSlug>]?: true }:{ [K in RelationshipKeysOf<TCollectionSlug>]?: { populate: DepthPopulate<RelationshipTargetOf<TCollectionSlug, K>, D, [..._Counter, 0]> } }
Defined in: packages/core/src/api/types.ts:446
Computes the equivalent PopulateShape for automatically populating all
relationship fields on TCollectionSlug to D levels deep.
This is the type-level counterpart of buildDepthPopulate. The computed
shape is a valid PopulateShape<TCollectionSlug> and can be fed directly into
Populated<TCollectionSlug, DepthPopulate<TCollectionSlug, D>>.
How the counter works: _Counter is a tuple of 0s whose length
tracks how many levels have been descended. At the penultimate level
([..._Counter, 0]["length"] extends D) fields are emitted as true
(populate, no further recursion). At intermediate levels they are emitted as
{ populate: DepthPopulate<Target, D, [..._Counter, 0]> }.
Practical depth limit: 3. TypeScript instantiation count grows
exponentially with D × relationship-key-count-per-collection. D=1,2,3 is
safe for typical VexCMS schemas; D≥4 may cause noticeable tsc slowdown.
Runtime has no limit.
Type Parameters
Section titled “Type Parameters”TCollectionSlug
Section titled “TCollectionSlug”TCollectionSlug extends CollectionSlug
The collection slug to start from.
D extends number
The depth as a literal number (1, 2, or 3 recommended).
_Counter
Section titled “_Counter”_Counter extends 0[] = []
Internal tuple counter — callers must not supply this.
Examples
Section titled “Examples”Resolved shape for depth 1 on posts with an author relationship
// DepthPopulate<"posts", 1> → { author?: true }// Equivalent to writing `populate: { author: true }` explicitlyResolved shape for depth 2
// DepthPopulate<"posts", 2> → { author?: { populate: { team?: true } } }// Equivalent to `populate: { author: { populate: { team: true } } }`