Skip to content

Commit 2aad034

Browse files
chore(): update README
1 parent ee5ab35 commit 2aad034

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

README.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ Now you can use `users[0].getName()` and `users[0].isAdult()` methods.
216216
This method transforms a plain javascript object to instance of specific class.
217217

218218
```typescript
219-
import { plainToClass } from 'class-transformer';
219+
import { plainToClass } from '@nestjs/class-transformer';
220220

221221
let users = plainToClass(User, userJson); // to convert user plain object a single user. also supports arrays
222222
```
@@ -237,7 +237,7 @@ let mixedUser = plainToClassFromExist(defaultUser, user); // mixed user should h
237237
This method transforms your class object back to plain javascript object, that can be `JSON.stringify` later.
238238

239239
```typescript
240-
import { classToPlain } from 'class-transformer';
240+
import { classToPlain } from '@nestjs/class-transformer';
241241
let photo = classToPlain(photo);
242242
```
243243

@@ -247,7 +247,7 @@ This method transforms your class object into a new instance of the class object
247247
This may be treated as deep clone of your objects.
248248

249249
```typescript
250-
import { classToClass } from 'class-transformer';
250+
import { classToClass } from '@nestjs/class-transformer';
251251
let photo = classToClass(photo);
252252
```
253253

@@ -258,7 +258,7 @@ You can also use an `ignoreDecorators` option in transformation options to ignor
258258
You can serialize your model right to json using `serialize` method:
259259

260260
```typescript
261-
import { serialize } from 'class-transformer';
261+
import { serialize } from '@nestjs/class-transformer';
262262
let photo = serialize(photo);
263263
```
264264

@@ -269,14 +269,14 @@ let photo = serialize(photo);
269269
You can deserialize your model from json using the `deserialize` method:
270270

271271
```typescript
272-
import { deserialize } from 'class-transformer';
272+
import { deserialize } from '@nestjs/class-transformer';
273273
let photo = deserialize(Photo, photo);
274274
```
275275

276276
To make deserialization work with arrays, use the `deserializeArray` method:
277277

278278
```typescript
279-
import { deserializeArray } from 'class-transformer';
279+
import { deserializeArray } from '@nestjs/class-transformer';
280280
let photos = deserializeArray(Photo, photos);
281281
```
282282

@@ -286,7 +286,7 @@ The default behaviour of the `plainToClass` method is to set _all_ properties fr
286286
even those which are not specified in the class.
287287

288288
```typescript
289-
import { plainToClass } from 'class-transformer';
289+
import { plainToClass } from '@nestjs/class-transformer';
290290

291291
class User {
292292
id: number;
@@ -313,7 +313,7 @@ If this behaviour does not suit your needs, you can use the `excludeExtraneousVa
313313
in the `plainToClass` method while _exposing all your class properties_ as a requirement.
314314

315315
```typescript
316-
import { Expose, plainToClass } from 'class-transformer';
316+
import { Expose, plainToClass } from '@nestjs/class-transformer';
317317

318318
class User {
319319
@Expose() id: number;
@@ -350,7 +350,7 @@ Lets say we have an album with photos.
350350
And we are trying to convert album plain object to class object:
351351

352352
```typescript
353-
import { Type, plainToClass } from 'class-transformer';
353+
import { Type, plainToClass } from '@nestjs/class-transformer';
354354

355355
export class Album {
356356
id: number;
@@ -398,7 +398,7 @@ the additional property `__type`. This property is removed during transformation
398398
```
399399

400400
```typescript
401-
import { Type, plainToClass } from 'class-transformer';
401+
import { Type, plainToClass } from '@nestjs/class-transformer';
402402

403403
export abstract class Photo {
404404
id: number;
@@ -446,7 +446,7 @@ in the options to keep the discriminator property also inside your resulting cla
446446
You can expose what your getter or method return by setting an `@Expose()` decorator to those getters or methods:
447447

448448
```typescript
449-
import { Expose } from 'class-transformer';
449+
import { Expose } from '@nestjs/class-transformer';
450450

451451
export class User {
452452
id: number;
@@ -472,7 +472,7 @@ If you want to expose some of the properties with a different name,
472472
you can do that by specifying a `name` option to `@Expose` decorator:
473473

474474
```typescript
475-
import { Expose } from 'class-transformer';
475+
import { Expose } from '@nestjs/class-transformer';
476476

477477
export class User {
478478
@Expose({ name: 'uid' })
@@ -498,7 +498,7 @@ Sometimes you want to skip some properties during transformation.
498498
This can be done using `@Exclude` decorator:
499499

500500
```typescript
501-
import { Exclude } from 'class-transformer';
501+
import { Exclude } from '@nestjs/class-transformer';
502502

503503
export class User {
504504
id: number;
@@ -517,7 +517,7 @@ Now when you transform a User, the `password` property will be skipped and not b
517517
You can control on what operation you will exclude a property. Use `toClassOnly` or `toPlainOnly` options:
518518

519519
```typescript
520-
import { Exclude } from 'class-transformer';
520+
import { Exclude } from '@nestjs/class-transformer';
521521

522522
export class User {
523523
id: number;
@@ -536,7 +536,7 @@ Now `password` property will be excluded only during `classToPlain` operation. V
536536
You can skip all properties of the class, and expose only those are needed explicitly:
537537

538538
```typescript
539-
import { Exclude, Expose } from 'class-transformer';
539+
import { Exclude, Expose } from '@nestjs/class-transformer';
540540

541541
@Exclude()
542542
export class User {
@@ -554,7 +554,7 @@ Now `id` and `email` will be exposed, and password will be excluded during trans
554554
Alternatively, you can set exclusion strategy during transformation:
555555

556556
```typescript
557-
import { classToPlain } from 'class-transformer';
557+
import { classToPlain } from '@nestjs/class-transformer';
558558
let photo = classToPlain(photo, { strategy: 'excludeAll' });
559559
```
560560

@@ -566,7 +566,7 @@ If you name your private properties with a prefix, lets say with `_`,
566566
then you can exclude such properties from transformation too:
567567

568568
```typescript
569-
import { classToPlain } from 'class-transformer';
569+
import { classToPlain } from '@nestjs/class-transformer';
570570
let photo = classToPlain(photo, { excludePrefixes: ['_'] });
571571
```
572572

@@ -575,7 +575,7 @@ You can pass any number of prefixes and all properties that begin with these pre
575575
For example:
576576

577577
```typescript
578-
import { Expose, classToPlain } from 'class-transformer';
578+
import { Expose, classToPlain } from '@nestjs/class-transformer';
579579

580580
export class User {
581581
id: number;
@@ -609,7 +609,7 @@ const plainUser = classToPlain(user, { excludePrefixes: ['_'] });
609609
You can use groups to control what data will be exposed and what will not be:
610610

611611
```typescript
612-
import { Exclude, Expose, classToPlain } from 'class-transformer';
612+
import { Exclude, Expose, classToPlain } from '@nestjs/class-transformer';
613613

614614
export class User {
615615
id: number;
@@ -633,7 +633,7 @@ If you are building an API that has different versions, class-transformer has ex
633633
You can control which properties of your model should be exposed or excluded in what version. Example:
634634

635635
```typescript
636-
import { Exclude, Expose, classToPlain } from 'class-transformer';
636+
import { Exclude, Expose, classToPlain } from '@nestjs/class-transformer';
637637

638638
export class User {
639639
id: number;
@@ -661,7 +661,7 @@ And you want to create a real javascript Date object from it.
661661
You can do it simply by passing a Date object to the `@Type` decorator:
662662

663663
```typescript
664-
import { Type } from 'class-transformer';
664+
import { Type } from '@nestjs/class-transformer';
665665

666666
export class User {
667667
id: number;
@@ -686,7 +686,7 @@ When you are using arrays you must provide a type of the object that array conta
686686
This type, you specify in a `@Type()` decorator:
687687

688688
```typescript
689-
import { Type } from 'class-transformer';
689+
import { Type } from '@nestjs/class-transformer';
690690

691691
export class Photo {
692692
id: number;
@@ -701,7 +701,7 @@ export class Photo {
701701
You can also use custom array types:
702702

703703
```typescript
704-
import { Type } from 'class-transformer';
704+
import { Type } from '@nestjs/class-transformer';
705705

706706
export class AlbumCollection extends Array<Album> {
707707
// custom array functions ...
@@ -751,7 +751,7 @@ For example, you want to make your `Date` object to be a `moment` object when yo
751751
transforming object from plain to class:
752752

753753
```typescript
754-
import { Transform } from 'class-transformer';
754+
import { Transform } from '@nestjs/class-transformer';
755755
import * as moment from 'moment';
756756
import { Moment } from 'moment';
757757

@@ -883,7 +883,7 @@ Circular references are not ignored only during `classToClass` operation.
883883
Lets say you want to download users and want them automatically to be mapped to the instances of `User` class.
884884

885885
```typescript
886-
import { plainToClass } from 'class-transformer';
886+
import { plainToClass } from '@nestjs/class-transformer';
887887

888888
this.http
889889
.get('users.json')

0 commit comments

Comments
 (0)