1
00:00:07,790 --> 00:00:13,790
Now that we are done with the user API creation, let's move to the account.

2
00:00:13,790 --> 00:00:16,020
So inside the controls.

3
00:00:16,040 --> 00:00:23,550
Now here is the account controller and we are done with the creation and then fetching all.

4
00:00:23,570 --> 00:00:31,760
So what we want to work on is to find a single account and this API is really important to us when you

5
00:00:31,760 --> 00:00:39,200
get to the front end because if you want to find a setting account with a transaction, we need this

6
00:00:39,200 --> 00:00:40,990
endpoint or controller.

7
00:00:41,000 --> 00:00:43,780
So let's see how we are going to get that one done.

8
00:00:43,790 --> 00:00:51,500
So first of all, we are going to find the account by it ID and you are going to find it inside the

9
00:00:51,500 --> 00:00:52,100
params.

10
00:00:52,130 --> 00:00:59,120
So let's check the endpoint for the account and here is the account collection folder and here is a

11
00:00:59,120 --> 00:00:59,840
single.

12
00:00:59,870 --> 00:01:04,190
When I hit send, it means that everything is working fine.

13
00:01:04,190 --> 00:01:08,300
So let's go to the controller and then implement the functionality.

14
00:01:08,300 --> 00:01:15,260
So first step is that find the ID from params.

15
00:01:16,250 --> 00:01:23,900
So if we console.log the red dot params dot id, so let's save it.

16
00:01:23,900 --> 00:01:27,230
And now let's see the ID that we are referring to.

17
00:01:27,230 --> 00:01:36,290
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

18
00:01:36,290 --> 00:01:37,430
of the accounts.

19
00:01:37,430 --> 00:01:45,170
So let's fetch all account and let's copy the ID for this account called Mom's Building Project.

20
00:01:45,350 --> 00:01:48,920
So inside a single here, I will provide it as that.

21
00:01:48,920 --> 00:01:53,930
And now I hit send and now I have the ID inside the terminal.

22
00:01:53,930 --> 00:01:58,790
So now I can go ahead and find the account by ID.

23
00:01:58,820 --> 00:02:01,010
So here we go.

24
00:02:01,010 --> 00:02:02,570
So I can go ahead.

25
00:02:02,570 --> 00:02:04,730
And then this structure, the ID.

26
00:02:04,760 --> 00:02:11,570
So const as ID is equal to rec dot params.

27
00:02:11,750 --> 00:02:12,620
Perfect.

28
00:02:13,040 --> 00:02:21,980
So next step is that let's find the account and it's equal to a weight and then the account model and

29
00:02:21,980 --> 00:02:26,780
find by ID and here I'll provide the ID.

30
00:02:26,810 --> 00:02:30,920
So next step is that let's send the response back to the user.

31
00:02:30,920 --> 00:02:42,650
So here let's remove this one and now let's provide status and you say is success and then the actual

32
00:02:42,650 --> 00:02:45,050
data is the account.

33
00:02:45,350 --> 00:02:51,440
So now let's check it out when we hit send, let's see and here we go.

34
00:02:51,650 --> 00:02:58,460
But upon fetching the account, I want to populate the transaction for this particular account.

35
00:02:58,490 --> 00:03:06,560
In that way we are going to use populates so here we can change the populate, but because for this

36
00:03:06,560 --> 00:03:15,740
one there is no nested ID, I can go ahead and use this format as transaction transaction.

37
00:03:15,830 --> 00:03:22,310
So now let's make the request to first single and let's see the response and here we go.

38
00:03:22,310 --> 00:03:28,700
So inside the front end, if you find a particular account, you'll be able to know the transaction

39
00:03:28,710 --> 00:03:35,720
about the account and we can go ahead and then filter out the transaction by the account type.

40
00:03:35,750 --> 00:03:41,000
So you can have a section for all expenses and then only for income.

41
00:03:41,000 --> 00:03:48,230
And we can do some mathematical operation to find the total expenses or total income or the total balance.

42
00:03:48,230 --> 00:03:53,720
So in the next video, let's go ahead and implement how we can update an account.

