Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Configuration module for Nest framework (node.js) 🐺

License

NotificationsYou must be signed in to change notification settings

nestjs/mapped-types

Repository files navigation

Nest Logo

A progressiveNode.js framework for building efficient and scalable server-side applications.

NPM VersionPackage LicenseNPM DownloadsDiscordBackers on Open CollectiveSponsors on Open Collective

Description

Mapped Types module forNest used by the@nestjs/graphql and@nestjs/swagger packages.

Installation

$ npm i --save @nestjs/mapped-types

Quick Start

As you build out features, it's often useful to construct variants on a base entity type. A good example of such a variant is aData Transfer Object (DTO). A Data Transfer Object is an object that is used to encapsulate data, and send it from one part of your application to another. DTO’s help us define the input and output interfaces of our system.

Let's imagine a real-world example, where we typically need to build both acreate andupdate variations for the same entity type.

The create variant may require all fields, while the update variant may make all fieldsoptional. Not to mention, both these types can also be variants of an entity type (to some extent).

That's a lot of redundant code!

Thus,NestJS now provides several utility functions that perform type transformations to help us avoid doing this, and make life a little bit easier.

Available mapped types:

  • PartialType - returns a type (class) with all the properties of the input type set to optional (requirement: at least 1 validation decorator applied to each property)
  • PickType - constructs a new type (class) by picking a set of properties from an input type
  • OmitType - constructs a type by picking all properties from an input type and then removing a particular set of keys
  • IntersectionType - combines two types into one new type (class)

Read more inthis article.

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, pleaseread more here.

Stay in touch

License

Nest isMIT licensed.

About

Configuration module for Nest framework (node.js) 🐺

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp