1.0.6 • Published 7 years ago

mapdtotoentity v1.0.6

Weekly downloads
1
License
ISC
Repository
github
Last release
7 years ago

mapdtotoentity

A tiny typescript package to map data transfer objects to entity class. (Especially TypeOrm entities)

Usage

- Install package

npm install mapdtotoentity

- Import module

import { mapDtoValuesToEntity } from 'mapdtotoentity/dist';

- Entity class

class MockEntity {\ x: string;\ y: number;\ }

- DTO class

class MockDTO {\ x: string;\ y: number;\ }

- Instantiate DTO class and add values

let dtoInstance = new MockDTO();\ dtoInstance.x = 'Something';\ dtoInstance.y = 40;

- Instantiate Mapper class;

const entityMapper = new mapDtoValuesToEntity<MockDTO, MockEntity>();

- Map DTO to Entity

const mapResult = entityMapper.map(dtoInstance, mockEntityInstance);

- Would print your entity class with all the values from DTO class

console.log(mapResult)

1.0.6

7 years ago

2.0.0

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago