Home Reference Source
import {SubTransformFieldMapper} from 'tilla/src/fieldMapper/subtransform.field.mapper.js'
public class | source

SubTransformFieldMapper

Extends:

src/fieldMapper/field.mapper~FieldMapper → SubTransformFieldMapper

A FieldMapper that uses a Transformer to map the field

Constructor Summary

Public Constructor
public

constructor(transformKey: string | Transformer | function(): Promise<Transformer>, permission: PermissionLvl)

Member Summary

Public Members
public
public
public

Method Summary

Public Methods
public

builder(instance: Object, key: string, isList: boolean): Promise

Transform the field on the instance, using another Transformer.

Private Methods
private

Public Constructors

public constructor(transformKey: string | Transformer | function(): Promise<Transformer>, permission: PermissionLvl) source

Params:

NameTypeAttributeDescription
transformKey string | Transformer | function(): Promise<Transformer>

If a string, it should be a key to locate the Transformer in the TransformerRegistry

  • The Transformer instance to use to perform the transformation
  • A function which returns a Promise<Transformer>
permission PermissionLvl

the permission to bind to the transformer function on the dto.

Public Members

public permission: * source

public transformKey: * source

public transformer: * source

Public Methods

public builder(instance: Object, key: string, isList: boolean): Promise source

Transform the field on the instance, using another Transformer. This can be used when transforming eargerly loaded relations on an instance ie. Family -> Person or obviously values we would like to transform using a prebuilt Transformer.

If the value being transformed is an Instance (Sequelize), we call its get() method to invoke all getters on fields and strip other Sequelize stuff off of the data before transforming it. @see http://docs.sequelizejs.com/class/lib/model.js~Model.html#instance-method-get

Params:

NameTypeAttributeDescription
instance Object

the source object.

key string
  • nullable: true

a key on the source object that can be used to retrieve the field value.

isList boolean
  • nullable: true

whether the value being transformed should be iterated into the builder.

Return:

Promise

a Promise that resolves to the transformed value.

Private Methods

private _setTransformer(): * source

Return:

*