Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,230 --> 00:00:04,535
So before moving on to implementing
2
00:00:04,535 --> 00:00:07,060
some more API features, let's now very quickly import
3
00:00:07,060 --> 00:00:09,120
the rest of our development data.
4
00:00:09,120 --> 00:00:11,913
So data on users, and on reviews.
5
00:00:13,520 --> 00:00:16,129
So, in our dev data folder,
6
00:00:16,129 --> 00:00:19,340
we already imported all the tours, right?
7
00:00:19,340 --> 00:00:23,920
But, we also have a users, and we also have reviews, okay?
8
00:00:23,920 --> 00:00:27,360
So, I have created a bunch of users for us to work with
9
00:00:27,360 --> 00:00:29,200
throughout the rest of the course,
10
00:00:29,200 --> 00:00:33,110
so all of these, I think it's about 20 users,
11
00:00:33,110 --> 00:00:36,400
and then also a bunch of reviews, okay.
12
00:00:36,400 --> 00:00:39,840
And so, all we need to do now is to basically update
13
00:00:39,840 --> 00:00:44,840
or import dev data script, so basically duplicate this here.
14
00:00:46,470 --> 00:00:50,200
So, tours will become users,
15
00:00:50,200 --> 00:00:54,860
and here tours will become reviews.
16
00:00:54,860 --> 00:00:57,793
Then, we also need to import the other two models,
17
00:01:01,770 --> 00:01:04,423
so review, and here as well.
18
00:01:13,290 --> 00:01:15,683
Now all right, and now then here,
19
00:01:16,750 --> 00:01:20,393
also, basically duplicate this, user,
20
00:01:23,500 --> 00:01:24,843
and review.
21
00:01:28,900 --> 00:01:29,733
All right.
22
00:01:30,960 --> 00:01:35,410
And that should probably do with the job, all right.
23
00:01:35,410 --> 00:01:39,160
So, let's go to our other terminal window here, clear this,
24
00:01:39,160 --> 00:01:42,173
and actually the last operation that we did was this one.
25
00:01:43,090 --> 00:01:45,853
So, we need to start by deleting everything we have.
26
00:01:48,070 --> 00:01:51,663
Oh, and I see now that we actually only deleted the tours.
27
00:01:52,570 --> 00:01:54,660
All right, and so we also want to get rid
28
00:01:54,660 --> 00:01:57,600
of all the current users that we have right now
29
00:01:57,600 --> 00:02:02,523
because they are really all just test users, all right.
30
00:02:03,770 --> 00:02:06,440
And the same of course goes for reviews.
31
00:02:06,440 --> 00:02:07,533
So, a gift is a save,
32
00:02:09,090 --> 00:02:11,403
and now deleting all of them,
33
00:02:12,660 --> 00:02:15,223
just taking a quick look into Compass,
34
00:02:16,680 --> 00:02:19,130
and so you see that, indeed, all the users are gone,
35
00:02:19,130 --> 00:02:22,623
and so the same should be true for the other collections.
36
00:02:24,260 --> 00:02:26,470
All right, and so now let's go ahead
37
00:02:26,470 --> 00:02:28,500
and import all of the data.
38
00:02:28,500 --> 00:02:30,500
That's gonna take a little bit of time,
39
00:02:30,500 --> 00:02:34,370
and now, we get this validation error here.
40
00:02:34,370 --> 00:02:37,470
Okay, so please confirm your password.
41
00:02:37,470 --> 00:02:40,770
And so, that's basically because we're creating a new user
42
00:02:40,770 --> 00:02:44,353
without specifying the password confirm property.
43
00:02:45,680 --> 00:02:49,140
So, the solution to that is to actually explicitly turn off
44
00:02:49,140 --> 00:02:52,420
the validation in this case, okay?
45
00:02:52,420 --> 00:02:55,160
And, I'm not sure if we have done that before,
46
00:02:55,160 --> 00:02:57,480
but it's actually very easy.
47
00:02:57,480 --> 00:02:59,730
Okay, so all we need to do is to pass in
48
00:02:59,730 --> 00:03:02,370
an additional object with some options,
49
00:03:02,370 --> 00:03:04,260
and actually in this case, just one.
50
00:03:04,260 --> 00:03:07,567
And, the option that we want is validateBeforeSave,
51
00:03:10,790 --> 00:03:13,040
and set it to false.
52
00:03:13,040 --> 00:03:16,080
Okay, and so with this, all of the validation that we do
53
00:03:16,080 --> 00:03:19,790
in the model will basically just be skipped, okay?
54
00:03:19,790 --> 00:03:21,780
Also, another thing that we need to do
55
00:03:21,780 --> 00:03:24,790
in the model is to turn off the password encryption
56
00:03:26,310 --> 00:03:29,360
because the users that we provide already have
57
00:03:29,360 --> 00:03:31,620
an encrypted password here, all right.
58
00:03:31,620 --> 00:03:34,690
And so, here in our user model,
59
00:03:34,690 --> 00:03:37,770
we now basically just need to comment out
60
00:03:37,770 --> 00:03:38,920
all of these (mumbles).
61
00:03:41,356 --> 00:03:42,340
Okay, and so now,
62
00:03:42,340 --> 00:03:46,030
the password encryption step is also gonna be skipped.
63
00:03:46,030 --> 00:03:47,380
So, we'll give this a save,
64
00:03:48,870 --> 00:03:53,573
and now lets, actually, first of all, delete the data again,
65
00:03:55,230 --> 00:03:57,990
just so we don't create any duplicates,
66
00:03:57,990 --> 00:04:02,890
and now let's try it again with import, and yeah.
67
00:04:02,890 --> 00:04:05,750
This time we didn't get any error,
68
00:04:05,750 --> 00:04:07,950
and so let's take a look at that in Compass,
69
00:04:12,620 --> 00:04:14,103
so we have all the users,
70
00:04:15,520 --> 00:04:17,853
we should have all natours as well.
71
00:04:19,490 --> 00:04:23,790
And, indeed, here they are, and also a couple of reviews.
72
00:04:23,790 --> 00:04:27,530
And, you'll see 60 reviews actually I created, okay?
73
00:04:27,530 --> 00:04:28,670
And let's just confirm
74
00:04:28,670 --> 00:04:32,150
that the passwords for users were not encrypted,
75
00:04:32,150 --> 00:04:35,780
so I'm just copying this one here, just this entire line.
76
00:04:35,780 --> 00:04:36,880
Oh, that doesn't work.
77
00:04:38,160 --> 00:04:39,960
So, let's just copy this string here
78
00:04:41,000 --> 00:04:43,950
and then compare with the one we have in our adjacent file.
79
00:04:47,600 --> 00:04:49,083
So, just the first one here,
80
00:04:50,070 --> 00:04:53,060
and yeah, indeed, you see that it looks
81
00:04:53,060 --> 00:04:56,220
exactly the same as this one, right?
82
00:04:56,220 --> 00:04:57,770
And so, just as we wanted,
83
00:04:57,770 --> 00:04:59,920
the passwords were not encrypted this time.
84
00:05:01,350 --> 00:05:04,260
Okay, so let's close all of this,
85
00:05:04,260 --> 00:05:08,010
make sure to remove the comments that we now put here,
86
00:05:08,010 --> 00:05:09,270
so that in the future of course,
87
00:05:09,270 --> 00:05:13,140
new users will then get their passwords encrypted properly.
88
00:05:13,140 --> 00:05:16,500
So, save this, and now I want to quickly take a look
89
00:05:16,500 --> 00:05:17,703
at the data here.
90
00:05:19,290 --> 00:05:21,850
So, in Postman, and the first thing
91
00:05:21,850 --> 00:05:25,323
that I want to do is to actually log in as an administrator.
92
00:05:28,740 --> 00:05:33,740
All right, so let's take a look at the email address,
93
00:05:33,820 --> 00:05:38,233
and so you see it's actually admin@natours.io, okay?
94
00:05:39,190 --> 00:05:42,650
And, of course the password, we cannot retrieve from here,
95
00:05:42,650 --> 00:05:47,460
but I know, of course, what password I specified,
96
00:05:47,460 --> 00:05:48,893
and so we can use that.
97
00:05:49,933 --> 00:05:50,766
And so, the password
98
00:05:50,766 --> 00:05:54,443
for all of the users here is always test1234, okay?
99
00:05:59,490 --> 00:06:01,320
So, that worked.
100
00:06:01,320 --> 00:06:04,530
So, again for all of the 20 users that I created,
101
00:06:04,530 --> 00:06:08,710
the password is always the same, always test1234.
102
00:06:08,710 --> 00:06:12,403
Great, now let's quickly get all tours here as well.
103
00:06:15,090 --> 00:06:20,090
And so, let's actually just remove this filter here.
104
00:06:23,560 --> 00:06:26,000
Okay, and so we get all our natours,
105
00:06:26,000 --> 00:06:29,830
and now you see that all of them now will have guides.
106
00:06:29,830 --> 00:06:33,253
Okay, so this is a lead guide and a normal guide,
107
00:06:34,820 --> 00:06:38,183
and also all of them will have a bunch of reviews.
108
00:06:39,470 --> 00:06:42,310
Somewhere, so that should be here,
109
00:06:42,310 --> 00:06:44,920
but I believe we only populated the reviews
110
00:06:44,920 --> 00:06:46,523
when we get just one tour,
111
00:06:47,460 --> 00:06:49,560
so that's try that here with the (mumbles).
112
00:06:50,510 --> 00:06:54,233
So, I copied the ID so that I can now put it in here.
113
00:06:55,640 --> 00:06:56,733
Let's send that,
114
00:06:58,110 --> 00:07:01,160
so the guides' locations,
115
00:07:01,160 --> 00:07:03,363
and indeed, now we get all of the reviews.
116
00:07:04,220 --> 00:07:06,900
And of course, just like we configured before
117
00:07:06,900 --> 00:07:09,547
here then the user also gets populated,
118
00:07:09,547 --> 00:07:10,803
and the tour does not.
119
00:07:12,100 --> 00:07:14,140
So, everything still works the same,
120
00:07:14,140 --> 00:07:17,460
but now we have a bunch of more real world data
121
00:07:17,460 --> 00:07:19,780
that we can now start working with
122
00:07:19,780 --> 00:07:21,480
throughout the rest of the course.
9747
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.