Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,130 --> 00:00:02,940
So now that you know the basics
2
00:00:02,940 --> 00:00:04,910
of Mongoose by implementing
3
00:00:04,910 --> 00:00:07,240
all the four correct operations,
4
00:00:07,240 --> 00:00:11,440
it's now to finally matter our tour data a bit better
5
00:00:11,440 --> 00:00:14,423
in order to make the tours more complete.
6
00:00:15,990 --> 00:00:20,240
So at this point, our tour documents can only have a name,
7
00:00:20,240 --> 00:00:22,410
a rating, and a price.
8
00:00:22,410 --> 00:00:25,060
But of course, we need so much more data here,
9
00:00:25,060 --> 00:00:29,320
because the goal is to have a very data-rich API,
10
00:00:29,320 --> 00:00:30,940
like this one.
11
00:00:30,940 --> 00:00:33,390
So let's take a look at the final version
12
00:00:33,390 --> 00:00:35,453
actually here as a reference.
13
00:00:36,660 --> 00:00:39,010
And so that's this one here.
14
00:00:39,010 --> 00:00:41,230
And so we get all tours,
15
00:00:41,230 --> 00:00:44,330
and it's gonna look a bit like this.
16
00:00:44,330 --> 00:00:46,620
Okay, so you see that on each tour,
17
00:00:46,620 --> 00:00:49,750
we have a start location, we have ratings average,
18
00:00:49,750 --> 00:00:52,543
ratings quantity, images, start dates.
19
00:00:53,410 --> 00:00:57,400
Guides, name, duration, maximum group size,
20
00:00:57,400 --> 00:00:58,910
difficulty, price, summary,
21
00:00:58,910 --> 00:01:01,323
description, image cover, locations.
22
00:01:02,930 --> 00:01:07,930
Even a slug, reviews, duration in weeks, and the ID.
23
00:01:07,960 --> 00:01:10,070
So you see a lot of data,
24
00:01:10,070 --> 00:01:12,860
and we're not gonna add all of the data
25
00:01:12,860 --> 00:01:14,260
in this lecture here.
26
00:01:14,260 --> 00:01:17,750
There are some pieces that we cannot add as of yet,
27
00:01:17,750 --> 00:01:22,330
but we can of course make it a bit more complete, okay?
28
00:01:22,330 --> 00:01:27,193
And let's actually save this here, like as a reference,
29
00:01:30,560 --> 00:01:33,550
and get all tours, and I'm gonna put it outside
30
00:01:34,630 --> 00:01:36,770
of any folder.
31
00:01:36,770 --> 00:01:39,643
So let's put it just here at the top.
32
00:01:40,810 --> 00:01:43,310
And that doesn't work for some reason.
33
00:01:43,310 --> 00:01:45,060
Okay, let's just put it here, then.
34
00:01:47,680 --> 00:01:50,903
Okay, let's get,
35
00:01:52,390 --> 00:01:53,550
that's correct.
36
00:01:53,550 --> 00:01:55,570
And so again, I'm leaving it here,
37
00:01:55,570 --> 00:01:58,400
in order to keep comparing what we have
38
00:01:58,400 --> 00:02:00,330
with what we're aiming for.
39
00:02:00,330 --> 00:02:02,870
So anyway, let's go back,
40
00:02:02,870 --> 00:02:05,250
and start with what we have already,
41
00:02:05,250 --> 00:02:06,560
and we have the name.
42
00:02:06,560 --> 00:02:08,520
And so that's already good enough,
43
00:02:08,520 --> 00:02:11,000
so for now I'm gonna leave it like this.
44
00:02:11,000 --> 00:02:16,000
So the name, then we also want a duration.
45
00:02:19,780 --> 00:02:24,780
And that duration is a number, and it is required.
46
00:02:26,570 --> 00:02:29,990
So set it to true, and then the message is,
47
00:02:29,990 --> 00:02:33,603
a tour must have a duration.
48
00:02:35,100 --> 00:02:38,450
So these required validators here basically
49
00:02:38,450 --> 00:02:40,870
are the only validators that I'm gonna add
50
00:02:40,870 --> 00:02:43,920
to each of these fields here for now.
51
00:02:43,920 --> 00:02:46,120
Later on, when we're going to talk more in detail
52
00:02:46,120 --> 00:02:48,790
about validators, we're gonna add a lot more.
53
00:02:48,790 --> 00:02:50,700
But again, for now, I just want to make
54
00:02:50,700 --> 00:02:54,150
some of these fields, not all of them, required.
55
00:02:54,150 --> 00:02:56,110
Next up, we have the group size.
56
00:02:56,110 --> 00:02:58,640
So basically, how many people can at most
57
00:02:58,640 --> 00:03:01,030
take part of one tour.
58
00:03:01,030 --> 00:03:03,560
And so I call that one the maxGroupSize.
59
00:03:06,530 --> 00:03:09,793
And so that again should be a number,
60
00:03:12,330 --> 00:03:17,070
and it is again required.
61
00:03:17,070 --> 00:03:22,070
Tour must have a group size.
62
00:03:24,150 --> 00:03:25,900
Don't forget the comma here.
63
00:03:25,900 --> 00:03:28,653
Next up, we also need a difficulty.
64
00:03:36,010 --> 00:03:39,470
And this one is a string, and later on,
65
00:03:39,470 --> 00:03:42,080
we will define that it should be either medium,
66
00:03:42,080 --> 00:03:44,920
easy, or difficult, but again,
67
00:03:44,920 --> 00:03:47,040
that is actually a validator,
68
00:03:47,040 --> 00:03:50,130
and I'm gonna leave that for a later time.
69
00:03:50,130 --> 00:03:52,440
Okay, for now, I'm just saying
70
00:03:52,440 --> 00:03:54,423
that it should have a difficulty.
71
00:03:58,640 --> 00:04:02,100
Next up, let's talk about the ratings.
72
00:04:02,100 --> 00:04:05,010
So right now we have a field called Rating,
73
00:04:05,010 --> 00:04:07,080
but in fact we want to have one field
74
00:04:07,080 --> 00:04:08,610
for the rating average,
75
00:04:08,610 --> 00:04:10,930
and one field for the ratings quantity.
76
00:04:10,930 --> 00:04:13,620
So basically the amount of ratings that there are.
77
00:04:13,620 --> 00:04:17,430
So later, there will be another resource called reviews,
78
00:04:17,430 --> 00:04:20,079
where users will be able to write reviews
79
00:04:20,079 --> 00:04:22,330
about tours and give ratings.
80
00:04:22,330 --> 00:04:25,030
And that's gonna be a completely different resource,
81
00:04:25,030 --> 00:04:27,060
and a completely different model.
82
00:04:27,060 --> 00:04:29,770
But still, we want to have basically a summary
83
00:04:29,770 --> 00:04:33,660
of these ratings and of these reviews here in the tours.
84
00:04:33,660 --> 00:04:36,630
Alright, and the reasons for that you will learn a bit later
85
00:04:36,630 --> 00:04:41,240
once we start how and why we model data in NoSQL databases,
86
00:04:41,240 --> 00:04:43,900
and specifically in MongoDB.
87
00:04:43,900 --> 00:04:47,913
Okay, for now, let's just add the ratings average,
88
00:04:49,150 --> 00:04:50,920
and the ratings quantity.
89
00:04:50,920 --> 00:04:53,220
Okay, so we leave this here as number,
90
00:04:53,220 --> 00:04:54,643
and with this default,
91
00:04:55,500 --> 00:04:58,590
and the ratings quantity, ratingsQuantity.
92
00:05:00,930 --> 00:05:03,803
That should of course also be a number,
93
00:05:06,490 --> 00:05:09,160
and the default will be zero.
94
00:05:09,160 --> 00:05:11,060
Because of course, in the beginning,
95
00:05:11,060 --> 00:05:14,183
there will be absolutely no reviews, when the tour is new.
96
00:05:15,590 --> 00:05:18,680
Now I didn't give these two properties here
97
00:05:18,680 --> 00:05:21,580
a required value, because it's not the user
98
00:05:21,580 --> 00:05:22,960
who creates these tours
99
00:05:22,960 --> 00:05:26,100
who will actually specify these values, right?
100
00:05:26,100 --> 00:05:27,720
So when we create a new tour,
101
00:05:27,720 --> 00:05:30,310
we will never specify the ratingsAverage,
102
00:05:30,310 --> 00:05:32,260
neither the ratingsQuantity,
103
00:05:32,260 --> 00:05:34,720
because that will later on be calculated
104
00:05:34,720 --> 00:05:37,570
from the real reviews, okay?
105
00:05:37,570 --> 00:05:40,040
Next up, we have the price here,
106
00:05:40,040 --> 00:05:41,920
so that's fine like this,
107
00:05:41,920 --> 00:05:44,403
and we might also have a discount.
108
00:05:45,390 --> 00:05:47,110
So let's say that this company,
109
00:05:47,110 --> 00:05:51,260
so Natours, wants to give a discount to one of the tours
110
00:05:51,260 --> 00:05:53,250
at some point, and so they can specify
111
00:05:53,250 --> 00:05:55,463
a discount price here as well.
112
00:05:57,090 --> 00:06:00,850
So priceDiscount, and so let's just put it here at number.
113
00:06:00,850 --> 00:06:03,220
We don't need any schema type options here.
114
00:06:03,220 --> 00:06:04,970
For example, it's not required,
115
00:06:04,970 --> 00:06:07,270
and so for now, let's just leave it like this.
116
00:06:08,170 --> 00:06:12,313
Next up, we can specify a summary of the tour.
117
00:06:14,120 --> 00:06:17,283
So the summary is of type String.
118
00:06:19,250 --> 00:06:22,040
But I will not actually make it required.
119
00:06:22,040 --> 00:06:24,540
Okay, and that's simply because it's not
120
00:06:24,540 --> 00:06:27,070
on the front page of our website.
121
00:06:27,070 --> 00:06:29,940
Okay, so basically it's not on the overview.
122
00:06:29,940 --> 00:06:31,800
And I'm gonna show you that in a second,
123
00:06:31,800 --> 00:06:33,070
but for now let me just add here
124
00:06:33,070 --> 00:06:36,330
another schema type option that I didn't show you yet,
125
00:06:36,330 --> 00:06:37,910
which is called trim.
126
00:06:37,910 --> 00:06:40,513
And trim only works for strings.
127
00:06:41,820 --> 00:06:43,650
And I will set it to true.
128
00:06:43,650 --> 00:06:46,710
So remember how I said that there are different schema types
129
00:06:46,710 --> 00:06:49,030
for different types here,
130
00:06:49,030 --> 00:06:52,320
and so for string, we have a schema type which is trim
131
00:06:52,320 --> 00:06:54,430
which will remove all the white space
132
00:06:54,430 --> 00:06:57,310
in the beginning and in the end of the string.
133
00:06:57,310 --> 00:07:00,363
Okay, and so if someone enters, for example,
134
00:07:01,570 --> 00:07:06,360
this tour, blah blah blah, doesn't matter.
135
00:07:06,360 --> 00:07:08,720
So if someone enters this,
136
00:07:08,720 --> 00:07:10,940
then all this whitespace in the end
137
00:07:10,940 --> 00:07:13,473
and in the beginning here will get cut.
138
00:07:15,190 --> 00:07:17,870
And actually, we can put the same thing on the name,
139
00:07:17,870 --> 00:07:19,003
for example, here.
140
00:07:20,810 --> 00:07:22,223
Okay, why not?
141
00:07:23,350 --> 00:07:24,720
So let's leave it like this.
142
00:07:24,720 --> 00:07:27,430
Here I see that it's actually called duration,
143
00:07:27,430 --> 00:07:28,403
not durations.
144
00:07:30,450 --> 00:07:35,240
Alright, so that's the summary, which is also misspelled.
145
00:07:35,240 --> 00:07:37,110
So summary like this.
146
00:07:37,110 --> 00:07:38,977
Oh, and yeah, now I wanted to show you
147
00:07:38,977 --> 00:07:40,633
the Natours website, actually.
148
00:07:42,090 --> 00:07:44,593
So that's back to our Mongoose documentation.
149
00:07:46,890 --> 00:07:48,890
But this is what I want to show you.
150
00:07:48,890 --> 00:07:53,540
So Natours.dev, which is the original of this application,
151
00:07:53,540 --> 00:07:56,740
and so this is the data that we have in our API,
152
00:07:56,740 --> 00:07:59,380
and that we also of course need in the database.
153
00:07:59,380 --> 00:08:00,770
So we have all this data.
154
00:08:00,770 --> 00:08:05,260
So this tour name, we have the difficulty,
155
00:08:05,260 --> 00:08:07,800
we have the duration, we have,
156
00:08:07,800 --> 00:08:10,930
this is a summary, then we have a start location,
157
00:08:10,930 --> 00:08:13,050
we have the amount of locations,
158
00:08:13,050 --> 00:08:14,800
we have a start date,
159
00:08:14,800 --> 00:08:17,602
we have the maximum group size in here,
160
00:08:17,602 --> 00:08:19,810
and we have to price, the rating average,
161
00:08:19,810 --> 00:08:21,193
the rating quantity.
162
00:08:22,050 --> 00:08:23,683
We also have an image here.
163
00:08:24,600 --> 00:08:27,833
And then here on the details page is where we have,
164
00:08:30,045 --> 00:08:32,120
we have the summary down here.
165
00:08:32,120 --> 00:08:36,330
We have the guides that I just showed you in Postman before.
166
00:08:36,330 --> 00:08:38,080
We have some more images.
167
00:08:38,080 --> 00:08:40,970
We have here all the locations,
168
00:08:40,970 --> 00:08:42,673
and we have all the reviews.
169
00:08:44,220 --> 00:08:47,570
Okay, so as I was telling you,
170
00:08:47,570 --> 00:08:51,340
not all the data is on the Overview page,
171
00:08:51,340 --> 00:08:54,500
and so not all the data is also required.
172
00:08:54,500 --> 00:08:57,623
Okay, so let's move back here.
173
00:08:58,490 --> 00:09:01,333
Next up, I want to add a description.
174
00:09:06,510 --> 00:09:10,283
And this is a type of String,
175
00:09:11,850 --> 00:09:14,740
and let's set trim to true again.
176
00:09:14,740 --> 00:09:16,520
And I just remembered that the summary
177
00:09:16,520 --> 00:09:19,250
is actually on the Overview page.
178
00:09:19,250 --> 00:09:22,280
And so let's make this one required.
179
00:09:22,280 --> 00:09:24,223
So you add here at the end,
180
00:09:27,010 --> 00:09:27,843
true,
181
00:09:30,220 --> 00:09:34,010
a tour must have a description.
182
00:09:34,010 --> 00:09:39,010
Okay, next up, we will specify the imageCover.
183
00:09:42,344 --> 00:09:45,320
And so that's the images that you see on the overview page
184
00:09:45,320 --> 00:09:48,463
and so let's set this one actually to require this role.
185
00:09:50,060 --> 00:09:52,880
So the type should be string,
186
00:09:52,880 --> 00:09:55,670
because basically this will simply be the name
187
00:09:55,670 --> 00:09:57,860
of the image here, which then later,
188
00:09:57,860 --> 00:10:01,050
we will be able to read from the file system.
189
00:10:01,050 --> 00:10:03,850
Okay, so really just the name of the image.
190
00:10:03,850 --> 00:10:07,040
So basically a reference will be stored in the database.
191
00:10:07,040 --> 00:10:09,530
And that's a very common practice, okay?
192
00:10:09,530 --> 00:10:13,270
So we could store the entire image as well in a database,
193
00:10:13,270 --> 00:10:15,400
but that's usually not a good idea.
194
00:10:15,400 --> 00:10:18,860
We simply leave the images somewhere in the file system
195
00:10:18,860 --> 00:10:21,340
and then put the name of the image itself
196
00:10:21,340 --> 00:10:22,823
in the database as a field.
197
00:10:24,370 --> 00:10:27,493
So set it to required, true,
198
00:10:28,560 --> 00:10:32,990
a tour must have a cover image.
199
00:10:32,990 --> 00:10:36,550
Nice, next one is the rest of the images.
200
00:10:36,550 --> 00:10:39,810
And now here, we have something new, okay?
201
00:10:39,810 --> 00:10:41,740
Because we have multiple images,
202
00:10:41,740 --> 00:10:44,750
and I want to save those images as an array.
203
00:10:44,750 --> 00:10:47,010
And actually, as an array of strings.
204
00:10:47,010 --> 00:10:50,110
And so the way to do it is to simplify specify here
205
00:10:50,110 --> 00:10:54,260
an array of strings, just like this.
206
00:10:54,260 --> 00:10:57,330
So I want it still to be of type string,
207
00:10:57,330 --> 00:10:59,230
but I want it to be an array.
208
00:10:59,230 --> 00:11:02,580
So an array in which we have a number of strings.
209
00:11:02,580 --> 00:11:06,441
And so that's how I can define this, okay?
210
00:11:06,441 --> 00:11:09,100
And we will use this later for something else again.
211
00:11:09,100 --> 00:11:11,750
And so we will then actually pass in
212
00:11:11,750 --> 00:11:14,680
more schema type options than just a type,
213
00:11:14,680 --> 00:11:18,660
and so by then we will use that again, alright?
214
00:11:18,660 --> 00:11:21,170
For now, though, let's move on,
215
00:11:21,170 --> 00:11:23,970
and the next field that I wanted to add here
216
00:11:23,970 --> 00:11:26,207
is the createdAt.
217
00:11:26,207 --> 00:11:29,230
And the createdAt field should basically be a timestamp
218
00:11:29,230 --> 00:11:33,290
that is set by the time that the user gets a new tour.
219
00:11:33,290 --> 00:11:36,433
So this here should of course be added automatically.
220
00:11:37,660 --> 00:11:40,580
Again, at the time the tour is created.
221
00:11:40,580 --> 00:11:42,580
So how do we do that?
222
00:11:42,580 --> 00:11:46,560
Well first of all, we set the type to Date.
223
00:11:46,560 --> 00:11:50,840
So Data is yet another JavaScript built-in datatype,
224
00:11:50,840 --> 00:11:52,253
and so we can use that here.
225
00:11:53,510 --> 00:11:56,210
Okay, so the type is Date,
226
00:11:56,210 --> 00:11:59,010
and then we simply need to set a default,
227
00:11:59,010 --> 00:12:00,840
and the default is the JavaScript
228
00:12:00,840 --> 00:12:04,870
built-in function Date.now.
229
00:12:04,870 --> 00:12:07,570
And I'm sure you are familiar with this one.
230
00:12:07,570 --> 00:12:11,390
So this will simply give us a timestamp in milliseconds,
231
00:12:11,390 --> 00:12:15,140
which basically represents the current millisecond.
232
00:12:15,140 --> 00:12:16,740
Alright, now in Mongo,
233
00:12:16,740 --> 00:12:20,390
this is now immediately converted to today's date
234
00:12:20,390 --> 00:12:24,153
in order to make more sense of this data, okay?
235
00:12:25,650 --> 00:12:30,650
So yeah, that's the automatically created timestamp.
236
00:12:30,900 --> 00:12:35,900
And now finally, we need to also pass in an array of dates.
237
00:12:36,400 --> 00:12:38,650
And now finally, to finish for now,
238
00:12:38,650 --> 00:12:43,033
we also want to able to define an array of start dates.
239
00:12:44,836 --> 00:12:49,500
So startDates, and again, we simply define an array,
240
00:12:49,500 --> 00:12:52,470
and then say that in there we want dates.
241
00:12:52,470 --> 00:12:56,240
Alright, so these startDates are basically different dates
242
00:12:56,240 --> 00:12:58,400
at which a tour starts.
243
00:12:58,400 --> 00:13:00,540
For example, we can have a tour starting
244
00:13:00,540 --> 00:13:02,280
in December this year,
245
00:13:02,280 --> 00:13:04,660
and then in February, the next year,
246
00:13:04,660 --> 00:13:06,580
and then another one in the summer,
247
00:13:06,580 --> 00:13:09,160
and so different dates for the same tour
248
00:13:09,160 --> 00:13:11,030
are simply different, let's say,
249
00:13:11,030 --> 00:13:14,550
instances of the tour starting on different dates.
250
00:13:14,550 --> 00:13:16,610
Alright, I hope that makes sense.
251
00:13:16,610 --> 00:13:19,730
Anyway, this one here will not be automatically created
252
00:13:19,730 --> 00:13:23,360
by MongoDB, and MongoDB will then automatically
253
00:13:23,360 --> 00:13:27,000
try to parse the string that we passed in as the date
254
00:13:27,000 --> 00:13:28,930
into a real JavaScript date.
255
00:13:28,930 --> 00:13:31,790
For example, we could pass in something like
256
00:13:31,790 --> 00:13:36,580
let's say 2021, March 21st,
257
00:13:36,580 --> 00:13:39,150
and again Mongo would then automatically parse
258
00:13:39,150 --> 00:13:41,199
this as a date.
259
00:13:41,199 --> 00:13:42,820
You can also specify the date.
260
00:13:42,820 --> 00:13:47,820
For example, saying 11 and 32 minutes, alright.
261
00:13:48,210 --> 00:13:51,800
Or we could also simply input a Unix timestamp,
262
00:13:51,800 --> 00:13:54,610
so a timestamp like in this format here.
263
00:13:54,610 --> 00:13:56,970
Okay, and so all of these formats,
264
00:13:56,970 --> 00:14:01,200
basically, Mongo will try to parse them into a date.
265
00:14:01,200 --> 00:14:03,853
And only if it can't, it will then throw an error.
266
00:14:04,762 --> 00:14:06,980
(exhales) So this was a lot of work.
267
00:14:06,980 --> 00:14:08,730
Let's give it a save here.
268
00:14:08,730 --> 00:14:11,530
And the way that we can then try this out
269
00:14:11,530 --> 00:14:13,850
is to go here to our dev-data,
270
00:14:13,850 --> 00:14:16,380
where we have this tour-simple.json file,
271
00:14:16,380 --> 00:14:19,343
which is the one we've been using in a previous section.
272
00:14:20,370 --> 00:14:21,790
All right.
273
00:14:21,790 --> 00:14:23,190
And so all I'm gonna do here
274
00:14:23,190 --> 00:14:26,023
is to just grab all this data here,
275
00:14:28,070 --> 00:14:33,070
and then use that one to create a new request, okay?
276
00:14:34,920 --> 00:14:38,170
So we want to create a new POST request here,
277
00:14:38,170 --> 00:14:39,500
and with all that data,
278
00:14:39,500 --> 00:14:41,650
instead of having to write it out manually.
279
00:14:42,660 --> 00:14:44,920
Okay, so pasting all of this here.
280
00:14:46,320 --> 00:14:49,580
And now indeed, we do not need the ID.
281
00:14:49,580 --> 00:14:50,750
So we needed it before,
282
00:14:50,750 --> 00:14:53,620
when we were doing our file-based API,
283
00:14:53,620 --> 00:14:57,200
but that's over now, so let's get rid of that.
284
00:14:57,200 --> 00:14:58,690
And so all the rest of the data
285
00:14:58,690 --> 00:15:02,250
that we marked that's required is now actually here,
286
00:15:02,250 --> 00:15:03,910
and even some more.
287
00:15:03,910 --> 00:15:07,593
So let's try to see what happens when we submit this.
288
00:15:08,500 --> 00:15:10,823
And now we get invalid data sent.
289
00:15:11,900 --> 00:15:16,450
So let's actually go to our tour controller,
290
00:15:16,450 --> 00:15:19,630
and in here, where we create a tour,
291
00:15:19,630 --> 00:15:22,610
instead of this message let's actually go back
292
00:15:22,610 --> 00:15:25,840
like we had it before and send the entire error
293
00:15:26,780 --> 00:15:29,633
just so we see what is actually going wrong.
294
00:15:30,800 --> 00:15:34,580
So send it here, okay, and the problem was
295
00:15:34,580 --> 00:15:37,483
that we have The Snow Adventure already defined.
296
00:15:38,550 --> 00:15:41,060
So let's first get rid of that.
297
00:15:41,060 --> 00:15:43,240
Yeah, so here we have The Snow Adventure,
298
00:15:43,240 --> 00:15:45,650
so we should delete this, and for that,
299
00:15:45,650 --> 00:15:49,130
I'm using our own API,
300
00:15:49,130 --> 00:15:51,713
so we can already put it to some use here.
301
00:15:53,100 --> 00:15:54,860
So that one should now be gone,
302
00:15:54,860 --> 00:15:58,690
and so now we should be able to add this as a new tour.
303
00:15:58,690 --> 00:16:01,590
And indeed, it's now here.
304
00:16:01,590 --> 00:16:05,040
So here is all the data that we just specified
305
00:16:05,040 --> 00:16:08,160
in this nice format.
306
00:16:08,160 --> 00:16:10,580
So what is interesting now is to actually see
307
00:16:10,580 --> 00:16:12,650
the createdAt timestamp.
308
00:16:12,650 --> 00:16:16,770
So that's the exact time at which I'm recording this video.
309
00:16:16,770 --> 00:16:19,480
And so this one was of course automatically created
310
00:16:19,480 --> 00:16:23,880
by this piece of code that we have somewhere here.
311
00:16:23,880 --> 00:16:24,853
Yeah, this.
312
00:16:25,970 --> 00:16:30,000
So that date is coming from this Date.now timestamp
313
00:16:30,000 --> 00:16:32,970
that JavaScript then automatically parses
314
00:16:32,970 --> 00:16:36,120
to this nice and readable date.
315
00:16:36,120 --> 00:16:39,290
Then here we have these arrays.
316
00:16:39,290 --> 00:16:41,407
Okay, so this array and another array,
317
00:16:41,407 --> 00:16:45,403
and of course, the automatically generated ID, alright?
318
00:16:46,740 --> 00:16:48,560
So if we come here now,
319
00:16:48,560 --> 00:16:50,940
we then have of course three tours.
320
00:16:50,940 --> 00:16:54,340
First, the other ones which are not so complete,
321
00:16:54,340 --> 00:16:56,510
and then all of these.
322
00:16:56,510 --> 00:16:59,450
Now what's interesting to see here is that Mongo
323
00:16:59,450 --> 00:17:04,050
also actually updated kind of the tours that we already had.
324
00:17:04,050 --> 00:17:06,290
So for example, we had rating here,
325
00:17:06,290 --> 00:17:08,750
but now that our schema completely changed,
326
00:17:08,750 --> 00:17:11,310
it then added this ratings average,
327
00:17:11,310 --> 00:17:15,599
and also this ratings quantity, both to their defaults,
328
00:17:15,599 --> 00:17:17,022
and the same actually here.
329
00:17:17,990 --> 00:17:20,410
It also created this timestamp.
330
00:17:20,410 --> 00:17:25,210
It created, yeah, it created images and start dates,
331
00:17:25,210 --> 00:17:27,079
with these empty arrays.
332
00:17:27,079 --> 00:17:29,373
And so it kind of changed all this data here.
333
00:17:30,240 --> 00:17:32,830
Alright, and so before we start moving on in a project,
334
00:17:32,830 --> 00:17:34,460
we should probably go ahead
335
00:17:34,460 --> 00:17:36,863
and delete all of this data here.
336
00:17:38,380 --> 00:17:40,800
And actually, what we're gonna do in the next video,
337
00:17:40,800 --> 00:17:43,660
now that our model is finally completed,
338
00:17:43,660 --> 00:17:45,250
at least for this section,
339
00:17:45,250 --> 00:17:47,410
we will go ahead and write a small script
340
00:17:47,410 --> 00:17:50,060
which will automatically import all of the tours
341
00:17:50,060 --> 00:17:51,713
from this JSON data.
342
00:17:52,550 --> 00:17:55,090
Okay, so from this JSON file, actually.
343
00:17:55,090 --> 00:17:57,170
So it will basically read the file,
344
00:17:57,170 --> 00:18:00,800
get all the tours, and import them into the database.
345
00:18:00,800 --> 00:18:03,830
Alright, so that's what we're gonna do next,
346
00:18:03,830 --> 00:18:06,160
because that will be hugely useful
347
00:18:06,160 --> 00:18:08,163
in this section and also in the future.
27040
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.