Hi everyone.
In this video, let's get on the bus.
Okay, but before that, in previous video, I completely forgot to put the user or the author over
here right now when we create a post, let me show you.
You can say we don't have the author property over here, right?
So in this video let's try to fix that inside the controller.
If you remember we already built the that I forget the current users, right?
And I will pass it right here inside the query method.
Let us.
And we need to this chapter in this thing and without our property we will put the current user over
here.
So let me say it again.
Go to the database.
And this already only half the author's property, right?
Well, in order to file on it.
Very easy.
We just need to use this plot box.
Model file.
Let me duplicate.
And get all users a box.
We already have, uh, access token and chain method to get.
Let me say right here, we already got the entire thing, but it just not good at all.
The reason?
Because right here, we don't have ability to know.
The bus over here belongs to what?
Users?
Okay, so how we can do that?
Well, let's see what the results we will expect.
Well, I expect it will have a something in here.
Well, firstly we read our ID okay.
And the second one will be our name.
And email.
And later for example we have an avatar.
We will use our avatar over here.
Okay.
But right now I want it will add a little bit of custom property.
Well, if you boost like this let me show you.
This is a custom property.
The reason is the customer update, because if you remember with all updates it will have inside a postman.
You can see it is exactly the same with the property, right?
But inside the database we don't have the author ID fields or author name authors email.
We don't have that right.
For that reason we will call this thing will be custom property.
And let me say, well, first of all, it will not work at all.
Can you guess why?
Well, the reason is simple because this is the custom property.
For that reason, we need to somehow customize the response of the detail.
Well, how to do dust in the cloud transformer package.
We have a.
One more decorator will be transformed from class transformers inside.
Here we will take a look at the object and I will console.log object for you.
So you will wrap it inside the object or directly destructuring.
And let me show you.
Let me say well if you look at right here we have the outer right.
We have outer.
It means this will console.log the original object from the response over here okay.
When it respond result, it will take a look directly inside the Insert object.
So with this guy we can popularize with the options.
Okay, we like the outdoors because in insert the schema we add the outer property.
Now let's say what is the response right now.
Well you can say it.
Auto destruct three.
Sorry it already populates the outer right.
With this thing we can return directly the object dot.
Name.
Sorry, this is the ID of the result we will update.
And later by and right here we dot name.
Sorry.
Here we object okay.
This is the object.
This is the next object, right?
And also we will fix the TypeScript.
Right now let me say uh, we got the internal server error we cannot reach from the uploaded file.
Can you guess why we have the error?
Cannot read property of undefined.
Well, the reason is simple, but I will show you how we can debug that fully.
I will console.log the object again.
And I will say if I say you can say right here we have one more property.
We have one more document.
I don't have the author, right.
So for that reason let's check the database and let's drop the collection.
Or you can drop entirely and recreate us again.
Let me go up.
Here.
Okay.
And let me get old, boss.
Now, you can say when we get old, boss.
We already have our name and our emails.
Okay, so that's what we want.
Let me create again.
And one more thing you can remember.
In order to create a boss, we don't need the author name or author email.
Okay.
We don't need that at all for that reason.
We don't need to populate us, but in order to populate inside, get inside the box method.
What do you want?
Of course we can try to get that and populate that and return the new data right here.
But I think that's not what we want okay.
We only want to create because we don't care about the response right here okay.
We don't care the response right here.
So for that reason this will be very enough.
But when we get we will for sure because we already mobilized.
Right.
So for that reason we will go now the name and email.
So that's about us.
And right here for more detail we can boost the a bit of checking.
And fitness on bass Rock, right?
Right here.
Let me put the some task with the object right here.
Railway boss.
Right.
Okay.
This will fix that issue.
So listen again.
Okay.
It's already work.
And you can see we have a list of problem.
When we retrieve the data, the ID right here will change.
The reason it change when we send.
Because right here we know it's exposed correctly.
So in the next video I will show you how we can fix that issue.