WEBVTT

00:00.960 --> 00:02.440
Hi everyone!

00:04.360 --> 00:10.720
In this video let's try the service to add the reactions into the box.

00:11.320 --> 00:19.360
Okay, well I think with that service we will write that inside the box service.

00:19.920 --> 00:20.440
Okay.

00:20.720 --> 00:28.600
I will not write the reaction into the reaction service okay.

00:28.600 --> 00:33.880
We call this action right here belong to the box right.

00:34.040 --> 00:44.080
I think this is some meaningful than add the logic inside the reaction okay.

00:47.440 --> 00:50.360
I will create a seat will be add reaction.

00:52.240 --> 00:53.920
And what is the deal.

00:54.800 --> 00:59.740
Let's say how we can add a little right here.

00:59.780 --> 01:05.940
Like, imagine what we will send inside here I will duplicate.

01:08.700 --> 01:13.900
And I will create a ask reaction I want.

01:14.060 --> 01:18.180
We will have an URL like that okay.

01:18.540 --> 01:21.820
So that was the reaction inside the body.

01:23.660 --> 01:30.340
Now if you take a look at the schema right here, it has a user boss.

01:30.900 --> 01:36.460
And right here right advertise.

01:36.580 --> 01:41.380
So I will create a boss okay.

01:41.420 --> 01:44.420
We can call the boss ID if you want.

01:46.980 --> 01:51.860
We don't need the user because we will rely on the access token.

01:53.420 --> 02:04.590
We need the type possible to be like us right now with this information.

02:05.310 --> 02:07.710
Let's build the details.

02:15.990 --> 02:16.710
Right here.

02:17.270 --> 02:21.670
And I will export class aggregation.

02:23.070 --> 02:23.830
Later.

02:27.110 --> 02:28.710
We will create a boss ID.

02:33.750 --> 02:34.870
And tie.

02:44.910 --> 02:46.270
With a tie right here.

02:47.270 --> 02:48.790
I reaction tie.

02:51.670 --> 02:52.150
Okay.

02:52.950 --> 03:01.970
And we to add a little bit of Checking validation is Mongo ID.

03:04.130 --> 03:04.610
Okay.

03:06.410 --> 03:11.330
And with that title here is it.

03:12.650 --> 03:14.530
And we will vote for some.

03:14.570 --> 03:15.170
All right.

03:15.690 --> 03:17.890
And you can take a look at the schema right here.

03:17.890 --> 03:29.050
And we arrive from the you know we lost or I think we can separate it into global.

03:31.850 --> 03:32.370
Okay.

03:33.170 --> 03:33.450
Mm.

03:37.530 --> 03:41.210
And in the worst why we can separate does.

03:44.210 --> 03:54.210
Is so here I will create a little box and I will create a log loss.

03:54.210 --> 03:54.430
Us too.

03:54.470 --> 03:54.830
Yes.

03:55.870 --> 03:56.430
Okay.

03:57.230 --> 03:59.870
And right here or.

04:02.070 --> 04:04.990
Actually, this is the dance that.

04:07.430 --> 04:08.950
I will dance with him.

04:09.830 --> 04:10.350
And both.

04:10.350 --> 04:10.950
Over here.

04:12.550 --> 04:13.470
Reaction.

04:16.310 --> 04:16.950
Times.

04:24.430 --> 04:27.430
And reaction time.

04:28.870 --> 04:34.470
And here will be also reaction time in focus.

04:40.270 --> 04:40.830
Okay.

04:42.430 --> 04:49.270
And right here we will have a art reaction.

04:50.710 --> 04:51.390
Little.

04:54.440 --> 04:56.000
And current users.

05:07.960 --> 05:11.840
And what we need to build the logic.

05:12.000 --> 05:13.360
Let me show you what you mean.

05:13.400 --> 05:19.000
Firstly, we need to file the existing.

05:21.840 --> 05:25.200
Existing reaction of the boss.

05:25.440 --> 05:25.960
Why?

05:27.200 --> 05:29.280
The reason we need to find existing.

05:29.280 --> 05:31.400
Because it later.

05:33.440 --> 05:33.920
If.

05:35.840 --> 05:40.160
If we find existing reaction.

05:41.320 --> 05:41.840
Okay.

05:42.480 --> 05:47.520
We need to update with the new.

05:50.320 --> 05:51.000
Reaction.

05:51.000 --> 05:52.060
Sometime, right?

05:52.460 --> 05:53.220
Possible.

05:55.260 --> 05:56.580
Inside the box one.

05:56.620 --> 05:56.820
Let.

05:56.860 --> 05:57.940
Let me show you.

05:57.940 --> 05:58.900
Inside the box one.

06:00.860 --> 06:07.140
The user one will like likes the box one, right?

06:07.500 --> 06:09.060
This is the last box one.

06:10.060 --> 06:18.620
Well, it later if we want to add the reaction into the box one.

06:18.660 --> 06:19.180
Also.

06:20.420 --> 06:30.940
Well, right here, because we already have the reaction of the box one with the user.

06:31.260 --> 06:34.660
So we will update okay.

06:34.700 --> 06:42.020
For example later we can update with the highway inside the box one.

06:42.140 --> 06:42.660
Okay.

06:44.860 --> 06:50.390
So that is that's the idea for the reason we need to find existing Reaction.

06:50.870 --> 06:54.390
If it's not clear, let's write code anyway.

06:54.430 --> 06:54.910
Clear.

06:55.230 --> 06:55.710
Okay.

06:56.830 --> 06:57.790
After we.

07:00.030 --> 07:01.270
Repeat this.

07:04.510 --> 07:05.470
We will bet.

07:05.510 --> 07:05.950
Okay.

07:05.950 --> 07:06.870
If not, is it?

07:10.590 --> 07:14.750
We will create a reaction.

07:15.390 --> 07:20.830
Okay, so let's step by step and write this thing.

07:21.590 --> 07:24.150
Firstly we need to find the existing reaction.

07:24.310 --> 07:24.790
Right.

07:32.830 --> 07:34.950
Well how we can find us.

07:35.270 --> 07:40.470
We need to inject the model after reaction.

07:40.470 --> 07:40.950
Right.

07:41.550 --> 07:43.870
But I don't want us at all.

07:46.630 --> 07:47.990
You can say right here.

07:48.410 --> 07:50.570
Hopefully I will remove the user model.

07:50.890 --> 07:58.810
I don't want to inject one more model again in setup I want to inject the service.

07:59.970 --> 08:08.730
So for that reason in this guy, we will delegate this logic right here into the reaction service.

08:09.130 --> 08:09.650
Okay.

08:09.690 --> 08:12.330
And we will inject the reactions of it.

08:12.370 --> 08:12.770
Okay.

08:12.770 --> 08:17.170
We will not inject in the schema.

08:17.490 --> 08:21.010
Instead we just need to inject the service.

08:21.370 --> 08:22.770
This is very good way.

08:22.970 --> 08:23.250
Okay.

08:23.250 --> 08:26.130
Let me show you what I mean right here.

08:26.970 --> 08:30.930
I will write the code a little bit inside the file.

08:30.930 --> 08:31.810
One right here.

08:33.530 --> 08:33.770
Oh.

08:36.610 --> 08:40.170
Actually, let me create another thing.

08:40.690 --> 08:41.770
We will find.

08:44.930 --> 08:45.250
Uh.

08:54.350 --> 08:55.230
Why is it going?

09:02.790 --> 09:03.310
Okay.

09:03.350 --> 09:12.110
I will create a function like that with Chatlog reaction id.

09:12.750 --> 09:13.190
Okay.

09:13.190 --> 09:18.790
This is clearly the reaction header and the user id.

09:19.230 --> 09:19.590
Okay.

09:19.630 --> 09:23.950
We will get us into this function and we will need to find us.

09:29.150 --> 09:31.950
Actually we just need to return directly over here.

09:33.670 --> 09:38.870
We need to inject the model.

09:43.310 --> 09:45.070
Let's see how we can inject us.

09:45.070 --> 09:49.280
Now let me get my entire constructor over here.

10:02.080 --> 10:03.160
Let's jump over here.

10:03.960 --> 10:04.480
Okay.

10:05.800 --> 10:10.080
And, uh, we need to insert a module also.

10:11.080 --> 10:13.800
Let me copy this thing.

10:16.320 --> 10:19.920
We will remove the user without this dot right now.

10:21.640 --> 10:26.640
Copy this import statement in here.

10:28.080 --> 10:28.800
What does.

10:43.940 --> 10:44.820
Emboss.

10:45.180 --> 10:46.140
Now let's say.

10:50.540 --> 10:51.060
Okay.

10:53.740 --> 10:55.380
Now let's reload it.

10:57.340 --> 10:59.660
We will find why this dot.

11:03.100 --> 11:04.060
Reaction.

11:09.500 --> 11:10.300
Asset model.

11:10.860 --> 11:12.340
Not find one.

11:13.380 --> 11:13.820
Okay.

11:13.860 --> 11:23.140
We will find it by following the reaction ID or actually went to file boss.

11:23.140 --> 11:27.180
Edit my boss over here.

11:28.260 --> 11:32.780
We must add a and the user id.

11:35.620 --> 11:36.140
Okay.

11:36.660 --> 11:38.660
That's the the first one.

11:39.060 --> 11:41.380
And inside the boss service.

11:41.660 --> 11:45.960
I want to inject and use this file sitting over here.

11:49.680 --> 11:50.080
Okay.

11:50.080 --> 11:53.280
In order to inject a service, we just need to call private.

11:56.440 --> 11:57.240
Collection.

11:57.880 --> 11:58.520
So we.

12:01.720 --> 12:04.560
Will serve it over here.

12:06.240 --> 12:06.720
Okay.

12:06.760 --> 12:08.280
We just need to inject us.

12:08.440 --> 12:10.520
And for sure it will get the error.

12:11.840 --> 12:21.480
In order to make this work inside the reaction module, we need to export the current service.

12:21.840 --> 12:22.120
Okay.

12:22.160 --> 12:27.840
The service we want to use in order module will be reaction service.

12:27.880 --> 12:28.320
Right.

12:30.440 --> 12:40.160
And from the the boss of it I will involve entire module.

12:49.450 --> 12:49.770
Now.

12:49.770 --> 12:50.250
Let's see.

12:52.690 --> 12:53.090
Okay.

12:53.130 --> 12:54.770
It will fix the issue.

12:55.370 --> 13:00.970
And right now, I hope you already understand from the Next.js.

13:01.210 --> 13:01.770
Okay.

13:02.290 --> 13:06.770
We already understand that from the Next.js fundamental, right?

13:07.130 --> 13:09.810
It doesn't complicate this at all.

13:11.690 --> 13:19.970
So after we already have a reaction service right here, I will use that.

13:32.210 --> 13:37.210
And we need to boost the boss ID.

13:37.730 --> 13:38.290
Right.

13:38.330 --> 13:43.110
We'll go From here, we can reach up that.

13:48.550 --> 13:48.910
High.

13:52.030 --> 13:52.790
What are these?

13:53.190 --> 13:57.750
And call user.id.

13:58.310 --> 13:58.710
Okay.

13:58.750 --> 14:01.870
We will find the boss over here.

14:04.990 --> 14:05.390
Sorry.

14:06.990 --> 14:09.510
Not find this thing.

14:10.390 --> 14:10.870
Okay.

14:11.150 --> 14:15.670
And right now we will have the existing for the current user.

14:16.830 --> 14:28.190
If the existing exit, we will update with the new reaction.

14:28.870 --> 14:29.430
Okay.

14:30.070 --> 14:36.670
And else we need to create the reaction for the boss.

14:36.710 --> 14:37.230
Okay.

14:37.230 --> 14:37.370
There.

14:37.770 --> 14:40.970
And inside the apron here we have one more condition.

14:41.450 --> 14:41.890
Okay.

14:42.810 --> 14:49.530
For example, if we already like an elixir, we will like that again.

14:49.850 --> 14:51.970
We will want it.

14:51.970 --> 14:53.770
Will not do anything, okay?

14:53.810 --> 14:55.290
Not do anything.

14:56.530 --> 15:02.850
If the new reaction equal without reaction.

15:02.890 --> 15:03.370
Okay.

15:04.010 --> 15:07.330
We need to write one more over here.

15:08.210 --> 15:14.090
So for that reason in this case we need to check the new reaction.

15:15.970 --> 15:16.450
Right.

15:17.410 --> 15:21.570
With the old reaction the old reaction between the existing reaction.

15:24.250 --> 15:36.050
Now right here I will show you if the ties equal with the existing reaction dot tie, we will not do

15:36.050 --> 15:36.620
know anything.

15:36.660 --> 15:36.980
Okay?

15:37.020 --> 15:38.980
We will return directly over here.

15:43.180 --> 15:45.260
And we need to update.

15:46.660 --> 15:50.460
After that, we will update with a new reaction.

15:50.460 --> 15:53.420
So we will write the service again.

15:53.900 --> 16:00.060
Inside here we got the update reaction right.

16:01.140 --> 16:03.700
Um right here.

16:07.420 --> 16:12.540
Let me say update with the new reaction.

16:13.860 --> 16:14.060
Uh.

16:16.140 --> 16:18.580
I will call uh why?

16:24.820 --> 16:32.140
This not present model of the file by ID and that.

16:35.080 --> 16:36.400
Right here we would add it.

16:37.400 --> 16:41.760
And so I will update the time.

16:42.480 --> 16:42.880
Okay.

16:42.920 --> 16:44.440
With the new time.

16:45.400 --> 16:48.320
So I think I will put directly the time over here.

16:50.200 --> 16:50.600
Hi.

16:53.120 --> 16:53.560
Hi.

16:56.120 --> 16:56.600
Hi.

17:00.800 --> 17:01.120
So.

17:21.520 --> 17:30.960
With the new video and we need to add a little bit of checking if we don't have reaction.

17:31.000 --> 17:35.220
The reason we not track right here because I want.

17:35.980 --> 17:38.940
We will check inside the boss service.

17:39.100 --> 17:39.380
Okay.

17:39.420 --> 17:42.220
But right now we can feel free to join us.

17:42.260 --> 17:42.620
Okay.

17:42.620 --> 17:45.100
It only depends on your requirement.

17:46.460 --> 17:48.700
Don't take this too much.

18:09.180 --> 18:13.820
And we have a error from the controller.

18:14.740 --> 18:19.860
I think we can remove entirely over here.

18:20.380 --> 18:24.580
Now let's start and remove the use imports.

18:27.540 --> 18:32.310
And over here we will update with the new reaction.

18:32.470 --> 18:32.990
Roy!

18:34.190 --> 18:35.030
Right here.

18:35.510 --> 18:36.310
Way to go.

18:36.350 --> 18:41.830
Why this dot reaction service dot update.

18:42.510 --> 18:45.350
We need to put the reaction ID.

18:50.110 --> 18:52.190
And the new type.

18:52.510 --> 18:56.510
The new type will come from the the type over here.

18:59.550 --> 19:00.030
Okay.

19:00.590 --> 19:08.710
We update with the new reaction and this type right here argument object.

19:08.710 --> 19:09.150
And.

19:13.630 --> 19:14.830
We will it.

19:14.830 --> 19:15.270
So.

19:18.590 --> 19:25.310
Right here I use string is not work right here.

19:25.350 --> 19:27.950
Let me try to convert it to string.

19:28.430 --> 19:34.810
If not I will convert it back to the object ID from here.

19:38.330 --> 19:39.690
Let's give it like this.

19:40.930 --> 19:49.730
And, uh, we need to create the reaction if we don't have the existing reaction.

19:49.730 --> 19:50.250
Right.

19:53.250 --> 19:58.130
So again we need to run it inside the service.

19:58.810 --> 20:00.050
Create over here.

20:07.810 --> 20:11.130
Right now we need to, uh.

20:13.570 --> 20:14.130
Put.

20:15.730 --> 20:16.690
Inside here.

20:16.730 --> 20:18.370
Create reaction.

20:19.650 --> 20:20.530
Little.

20:25.010 --> 20:25.330
Uh.

20:27.690 --> 20:28.740
It will here.

20:29.180 --> 20:39.300
So I think in this case we just need to use the add reaction video.

20:39.540 --> 20:39.980
Okay.

20:40.740 --> 20:41.500
From here.

20:45.220 --> 20:46.740
And let's create us.

21:01.820 --> 21:02.580
The user.

21:16.540 --> 21:17.460
From the sky.

21:19.620 --> 21:22.820
And return reaction dot save method.

21:23.180 --> 21:23.580
Okay.

21:23.620 --> 21:25.660
This will be for create method.

21:26.660 --> 21:34.320
Let's Let me move some stuff over here and, uh, go back to reaction controller and remove this thing

21:34.400 --> 21:36.320
so we don't miss that.

21:43.360 --> 21:43.880
Okay.

21:44.080 --> 21:45.280
It's ah, sweet.

21:45.280 --> 21:47.480
Let's go back and go.

21:52.240 --> 21:54.960
With no, ah, reaction.

21:59.600 --> 22:01.720
Uh, we can go here.

22:03.280 --> 22:04.440
Reaction video.

22:06.560 --> 22:11.200
And the current user mode over here.

22:11.600 --> 22:12.080
Okay.

22:12.600 --> 22:13.080
So.

22:14.480 --> 22:18.120
And, uh, we haven't completed yet.

22:18.480 --> 22:20.840
After here, we need to update.

22:21.600 --> 22:26.780
Uh, we need to update the reaction cow right here also.

22:27.020 --> 22:27.460
Right.

22:28.220 --> 22:28.860
We need to.

22:32.260 --> 22:36.660
Uh, get reaction now.

22:36.980 --> 22:38.780
But that for the next video.

22:39.540 --> 22:42.540
Uh, let me taste that.

22:44.460 --> 22:44.940
Okay.

22:45.380 --> 22:46.740
Let me taste that a bit.

22:49.140 --> 22:49.780
Okay.

22:58.820 --> 22:59.260
Right here.

22:59.260 --> 23:01.420
I will get on, uh, boss.

23:02.740 --> 23:03.500
Right here.

23:05.820 --> 23:06.740
We have the ID.

23:09.300 --> 23:10.740
Is that the ad reaction?

23:10.860 --> 23:12.820
We need to create the controller.

23:27.310 --> 23:30.470
Most over here are Russian.

23:48.310 --> 23:49.470
General.

23:56.510 --> 23:57.390
Something like that.

23:57.430 --> 23:57.870
Okay.

24:03.510 --> 24:05.790
Now let me take that.

24:06.230 --> 24:12.310
I will boost the ID over here with the tie.

24:12.350 --> 24:13.430
Will be like.

24:13.790 --> 24:17.510
Let me say we have already got the success.

24:17.950 --> 24:19.750
And let's check the data by.

24:41.130 --> 24:41.610
Right here.

24:41.610 --> 24:47.010
We already got a tie with the users.

24:47.570 --> 24:48.210
Ready?

24:50.970 --> 24:53.370
Uh, but.

24:56.490 --> 24:58.450
I don't see the boss.

24:59.130 --> 25:01.530
Oh, my bad, my bad.

25:02.370 --> 25:03.490
The reason?

25:04.250 --> 25:07.450
Because inside here.

25:10.930 --> 25:12.490
This is the boss.

25:12.530 --> 25:16.690
And this is the boss ID, right?

25:17.930 --> 25:21.790
I want Every name is.

25:23.910 --> 25:24.870
Big win right here.

25:27.110 --> 25:28.950
Uh, we need to.

25:31.110 --> 25:31.870
Add a bit.

25:33.470 --> 25:42.670
If you say inside the create method, we take a look at video.

25:43.710 --> 25:44.270
Right.

25:45.870 --> 25:46.630
We need to.

25:46.670 --> 25:47.270
Right.

25:48.350 --> 25:49.830
Mouse over here.

25:50.310 --> 25:55.750
We will create last body and.

25:55.750 --> 25:56.270
Hi.

25:59.350 --> 25:59.830
Okay.

26:00.710 --> 26:05.150
We need to change a little bit over here and let me undo.

26:07.030 --> 26:07.390
Okay.

26:07.390 --> 26:08.430
This will work right now.

26:12.710 --> 26:17.910
Before that let me remove the document.

26:20.360 --> 26:21.280
Let me say it again.

26:23.560 --> 26:24.880
And let's refresh.

26:34.360 --> 26:40.560
Okay, well, now we already lost the boss lady right here and right here.

26:42.280 --> 26:42.760
Okay.

26:44.280 --> 26:47.320
And it all works.

26:47.640 --> 26:51.800
But right now, if you save the boss over here.

26:53.880 --> 26:54.440
We.

26:54.880 --> 27:00.000
We need to update the count for us, right?

27:01.720 --> 27:03.960
So not for the next video.

27:05.880 --> 27:09.480
And I hope you understand the losses over here.

27:09.520 --> 27:13.920
Okay, so if not, let's take a little bit.

27:14.480 --> 27:16.480
I'm sure you will like that.

27:16.800 --> 27:18.360
I will see you in the next one.
