nest decorators

@Body
We use @Body(‘title’) to access title field inside request post body. 
This means it will take the Post what you passed and post on every field
where there's 'title'. If the @Body() decorator has nothing inside the 
parenthasis, then it means you're creating a new object that will have a 
different value for every key in the object. Next to the decorator you 
must pass the new object of type Dto/model you want to post/add to the 
database.
Example...if @Body() & new object you're adding then : 
 { 
	id: 3,
    name: somethingNew,
    color: brown
 }
 You're adding a whole new object and not targeting any field in the
 existing objects.
 
 @Param
 @Param(‘id’) will automatically capture this param for us. it's a way to
 tell the array of objects in the database that we're looking for 
 something where the id we passed is found.
 
 @Query()
 it's like a forEach(variable=>{}).....You have to give it a variable 
 that will loop/query around all the objects in the array then you can 
 give it what property you are looking for by using that variable
 
 Example:
 
 { 
	id: 3,
    name: somethingNew,
    color: brown
 }
 
 @Query() query //variable
 query.id or query.name or query.color

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source