Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ModelTransformer

Helper class for converting plain objects to Entities (Table-decorated classes).

Hierarchy

  • ModelTransformer

Index

Constructors

Methods

Constructors

constructor

Methods

transform

  • transform<T>(obj: object, Entity: EntityType<T>): Promise<T>
  • Transform obj to an instance of type T.

    Type parameters

    • T

    Parameters

    • obj: object

      The object, which will be validated using a ModelValidator instance, and then transformed into an entity of type T.

    • Entity: EntityType<T>

      The constructor of a Table-decorated class. obj will be transformed into one of these entities.

    Returns Promise<T>

    A promise that will be resolved with an EntityType instance, or rejected with a validation error if the transformation is not possible.

Generated using TypeDoc