1
00:00:00,180 --> 00:00:00,510
All right.

2
00:00:00,540 --> 00:00:06,120
And in order to complete our register controller, we need to figure out what we're doing with a password

3
00:00:06,720 --> 00:00:12,990
because at the moment we're sending it back to the front end, which is not something that we want to

4
00:00:12,990 --> 00:00:13,200
do.

5
00:00:14,260 --> 00:00:17,440
And essentially, we have multiple approaches.

6
00:00:17,920 --> 00:00:27,160
And one of them is in the schema where in the Mongoose we can actually use select property and notice

7
00:00:27,610 --> 00:00:31,360
if it's true, the path should always be included in the results.

8
00:00:32,020 --> 00:00:35,740
But if it's false, then it's going to be excluded by default.

9
00:00:36,190 --> 00:00:43,750
And what's really cool is that we can override this on a query level, so essentially notice you're

10
00:00:43,810 --> 00:00:45,640
able to select true or false.

11
00:00:46,180 --> 00:00:54,400
And then when you're setting the query, you can say, Hey, listen, I know that I set up this property

12
00:00:54,400 --> 00:00:56,230
to be excluded or included.

13
00:00:56,470 --> 00:01:03,820
And actually, I want to include that in the query, and I'll show you in our project as well so where

14
00:01:03,820 --> 00:01:05,319
you'll have a better understanding?

15
00:01:05,620 --> 00:01:11,020
Now here's the gotcha, though, since we use user not create, it is not going to work.

16
00:01:11,050 --> 00:01:12,460
So let me showcase that first.

17
00:01:12,850 --> 00:01:17,560
When I want to do is go to use their dash and then where I have the password, I'm going to go with

18
00:01:17,620 --> 00:01:20,320
select and I'll serve equal to force.

19
00:01:20,650 --> 00:01:21,970
So I don't want to share that.

20
00:01:22,450 --> 00:01:28,360
For example, if I'm going to use find one, then password will be excluded.

21
00:01:28,750 --> 00:01:34,530
However, in this case, like I just mentioned, since we're using user create, we'll still get back

22
00:01:34,540 --> 00:01:38,740
the password and I know that some people might find this annoying.

23
00:01:38,740 --> 00:01:45,040
But let me showcase that where essentially everything is saved here, everything works properly.

24
00:01:45,280 --> 00:01:49,120
And then once I send, yep, I still have the password.

25
00:01:49,450 --> 00:01:51,490
So in this case, we have two options.

26
00:01:52,120 --> 00:01:58,480
We can create utils folder and just create a function that gets me the powers that I'm looking for.

27
00:01:58,990 --> 00:02:05,230
Effectively, what I want to get is email, last name, location and name that's going to be set up

28
00:02:05,230 --> 00:02:14,500
here in this user object or in this case, I can just them now since in the login and update, user

29
00:02:14,710 --> 00:02:16,210
will use different methods.

30
00:02:16,630 --> 00:02:20,260
So we're not going to use, create and effectively.

31
00:02:20,380 --> 00:02:25,000
By doing so, we won't get back to password, which is exactly what I'm looking for.

32
00:02:25,510 --> 00:02:26,050
In this case.

33
00:02:26,060 --> 00:02:27,520
I'll just add code again.

34
00:02:28,180 --> 00:02:33,400
If there's multiple places where you need to do that, it kind of makes sense to set up the function.

35
00:02:33,790 --> 00:02:35,620
So in this case, here's what I want to do.

36
00:02:35,920 --> 00:02:42,550
I simply want to go with the user that's going to be my object, and I'll say email is equal to use

37
00:02:42,550 --> 00:02:47,530
their email than the last name will be equal to what we'll well, user.

38
00:02:47,830 --> 00:02:50,260
And then that and last name, correct?

39
00:02:50,350 --> 00:02:54,340
So that's what we're sending back and we want to do the same thing with location.

40
00:02:54,820 --> 00:02:57,250
That's going to be user and location.

41
00:02:57,550 --> 00:03:03,790
And then lastly, you can probably already guess that we're going to be looking for name and user not

42
00:03:03,790 --> 00:03:04,090
name.

43
00:03:04,120 --> 00:03:09,220
Again, I fully understand that you're looking at this location here and like, What is wrong with you,

44
00:03:09,220 --> 00:03:09,560
man?

45
00:03:09,610 --> 00:03:10,570
Why are doing this?

46
00:03:10,840 --> 00:03:16,790
Trust me, once we get to this point on the front end, you'll see why we're doing these acrobatics.

47
00:03:16,810 --> 00:03:24,310
So, yes, the select force works really nicely, but not with this particular dart create.

48
00:03:24,400 --> 00:03:28,600
So let me navigate quickly back to my database.

49
00:03:29,110 --> 00:03:36,910
Let me remove the John one more time, and then let's try it out where in our response, we should get

50
00:03:36,910 --> 00:03:40,420
the properties that we just set up in the user object.

51
00:03:40,540 --> 00:03:41,740
So let me send it.

52
00:03:42,100 --> 00:03:43,000
And what do you know?

53
00:03:43,430 --> 00:03:49,870
I have email, last name, location and there not much is exactly what I was setting up over here.

54
00:03:50,230 --> 00:03:52,930
And with this in place now, we can move on to our next step.

