AdonisJS API
    Preparing search index...

    Interface CollectionContract<Transformer, MaxDepth, Variant>

    Contract interface for Collection instances used in type inference. A Collection represents an array of resources that will be transformed using the specified transformer class.

    interface CollectionContract<
        Transformer extends Record<string, any>,
        MaxDepth extends Next[number],
        Variant extends string,
    > {
        $type: "collection";
        transformer: new (...args: any[]) => Transformer;
        maxDepth: MaxDepth;
        variant: Variant;
    }

    Type Parameters

    • Transformer extends Record<string, any>

      The transformer class to use for transforming each resource

    • MaxDepth extends Next[number]

      The maximum depth for nested resource resolution

    • Variant extends string

      The variant method name to use for transformation

      const usersCollection: CollectionContract<UserTransformer, 3, 'toObject'> = {
      $type: 'collection',
      transformer: UserTransformer,
      maxDepth: 3,
      variant: 'toObject'
      }
    Index
    $type: "collection"

    Discriminator property to identify this as a Collection type

    transformer: new (...args: any[]) => Transformer

    The transformer class constructor used for transforming each resource

    maxDepth: MaxDepth

    Maximum depth for resolving nested resources

    variant: Variant

    The variant method name to call on the transformer