File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -186,6 +186,17 @@ import {plainToClass} from "class-transformer";
186
186
let users = plainToClass(User, userJson); // to convert user plain object a single user. also supports arrays
187
187
` ` `
188
188
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
+
189
200
#### classToPlain
190
201
191
202
This method transforms your class object back to plain javascript object , that can be `JSON .stringify ` later .
@@ -794,4 +805,4 @@ usages.
794
805
795
806
## Release notes
796
807
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 ) .
You can’t perform that action at this time.
0 commit comments