Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Transferable<TDTOType> Abstract

label

COMMON

description

This concern requires the presence of fields that consist in delivering transferable information. This concerns data that can be persisted in the mongo database but also transferred (DTOs).

This class defines a generic type template DTOType that should be used with DTO classes, e.g. StateDTO, AccountDTO, etc.

We provide a base implementation for the {@link toDTO} method to standardize the retrieval and formatting of DTOs from their origin database documents.

example

Extending and using the Transferable

 import { Transferable } from "./Transferable";

class Example extends Transferable<ExampleDTO> {
@Prop()
testProp: string;

// Overrides from Transferable
public static fillDTO(doc: ExampleDocument, dto: ExampleDTO) {
dto.testProp = doc.testProp;
return dto;
}
}
abstract
since

v0.2.0

Type Parameters

Hierarchy

Index

Constructors

Methods

Constructors

Methods

  • fillDTO(doc: any, dto: any): any
  • This static method populates a DTO object from the values of a document as presented by mongoose queries.

    CAUTION: This method must be implemented in child classes in order to provide restricted transferable fields. This method should not be used directly as it does no exclusion of fields as would be usual for transferable DTOs.

    internal

    This method should not be used directly. Use child classes' implementation instead.

    access

    public

    static

    Parameters

    • doc: any

      The document as received from mongoose.

    • dto: any

      The DTO object that will be populated with values.

    Returns any

    The dto object with fields set.

Generated using TypeDoc