Skip to content

Commit dff2aff

Browse files
MTschannettNoNameProvided
authored andcommitted
docs: add minimal docs for plainToClassFromExist
1 parent e6e8b82 commit dff2aff

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,17 @@ import {plainToClass} from "class-transformer";
186186
let users = plainToClass(User, userJson); // to convert user plain object a single user. also supports arrays
187187
```
188188

189+
#### plainToClassFromExist
190+
191+
This method transforms a plain object into a instance using a already filled Object which is a instance from the target class.
192+
193+
```typescript
194+
const defaultUser = new User();
195+
defaultUser.role = 'user';
196+
197+
let mixedUser = plainToClassFromExist(defaultUser, user); // mixed user should have the value role = user when no value is set otherwise.
198+
```
199+
189200
#### classToPlain
190201

191202
This method transforms your class object back to plain javascript object, that can be `JSON.stringify` later.
@@ -794,4 +805,4 @@ usages.
794805

795806
## Release notes
796807

797-
See information about breaking changes and release notes [here](https://github.com/pleerock/class-transformer/tree/master/doc/release-notes.md).
808+
See information about breaking changes and release notes [here](https://github.com/pleerock/class-transformer/tree/master/doc/release-notes.md).

0 commit comments

Comments
 (0)