1.0.6 • Published 6 years ago

mapdtotoentity v1.0.6

Weekly downloads
1
License
ISC
Repository
github
Last release
6 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

6 years ago

2.0.0

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago