Now that we are done with the user API creation, let's move to the account.
So inside the controls.
Now here is the account controller and we are done with the creation and then fetching all.
So what we want to work on is to find a single account and this API is really important to us when you
get to the front end because if you want to find a setting account with a transaction, we need this
endpoint or controller.
So let's see how we are going to get that one done.
So first of all, we are going to find the account by it ID and you are going to find it inside the
params.
So let's check the endpoint for the account and here is the account collection folder and here is a
single.
When I hit send, it means that everything is working fine.
So let's go to the controller and then implement the functionality.
So first step is that find the ID from params.
So if we console.log the red dot params dot id, so let's save it.
And now let's see the ID that we are referring to.
So let's hit send and you can see that I have the ID here, so now we can go ahead and then copy one
of the accounts.
So let's fetch all account and let's copy the ID for this account called Mom's Building Project.
So inside a single here, I will provide it as that.
And now I hit send and now I have the ID inside the terminal.
So now I can go ahead and find the account by ID.
So here we go.
So I can go ahead.
And then this structure, the ID.
So const as ID is equal to rec dot params.
Perfect.
So next step is that let's find the account and it's equal to a weight and then the account model and
find by ID and here I'll provide the ID.
So next step is that let's send the response back to the user.
So here let's remove this one and now let's provide status and you say is success and then the actual
data is the account.
So now let's check it out when we hit send, let's see and here we go.
But upon fetching the account, I want to populate the transaction for this particular account.
In that way we are going to use populates so here we can change the populate, but because for this
one there is no nested ID, I can go ahead and use this format as transaction transaction.
So now let's make the request to first single and let's see the response and here we go.
So inside the front end, if you find a particular account, you'll be able to know the transaction
about the account and we can go ahead and then filter out the transaction by the account type.
So you can have a section for all expenses and then only for income.
And we can do some mathematical operation to find the total expenses or total income or the total balance.
So in the next video, let's go ahead and implement how we can update an account.