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