﻿1
00:00:01,100 --> 00:00:02,990
‫{\an8}Let's now take a small break

2
00:00:02,990 --> 00:00:04,900
‫{\an8}from building our API

3
00:00:04,900 --> 00:00:07,080
‫{\an8}and build a fun little script

4
00:00:07,080 --> 00:00:10,430
‫{\an8}that will import the tour data from our JSON file

5
00:00:10,430 --> 00:00:12,930
‫{\an8}into the MongoDB database.

6
00:00:12,930 --> 00:00:14,240
‫{\an8}And I wasn't really sure

7
00:00:14,240 --> 00:00:16,850
‫{\an8}if I should include this video in the course

8
00:00:16,850 --> 00:00:19,620
‫{\an8}or if I should just come with the script

9
00:00:19,620 --> 00:00:22,690
‫{\an8}already in the course starter files.

10
00:00:22,690 --> 00:00:25,710
‫{\an8}But I thought I thought it was a nice little exercise

11
00:00:25,710 --> 00:00:27,560
‫{\an8}and so I included it anyways.

12
00:00:27,560 --> 00:00:30,023
‫{\an8}So, anyway, let's now get started.

13
00:00:31,860 --> 00:00:34,233
‫So, basically we're gonna create a script

14
00:00:34,233 --> 00:00:37,200
‫that will simply load the data from the JSON file

15
00:00:37,200 --> 00:00:39,730
‫as I just said into the database.

16
00:00:39,730 --> 00:00:42,090
‫And this script is completely independent

17
00:00:42,090 --> 00:00:44,560
‫of the rest of our express application.

18
00:00:44,560 --> 00:00:46,990
‫And so we'll run this completely separately

19
00:00:46,990 --> 00:00:50,720
‫from the comment line just to import everything once.

20
00:00:50,720 --> 00:00:53,310
‫Okay, so let me actually create the script

21
00:00:53,310 --> 00:00:56,330
‫right here in the data folder.

22
00:00:56,330 --> 00:00:57,433
‫So new file,

23
00:00:58,780 --> 00:00:59,623
‫import,

24
00:01:01,240 --> 00:01:03,543
‫dev data.js.

25
00:01:04,400 --> 00:01:05,380
‫All right.

26
00:01:05,380 --> 00:01:07,810
‫So, what are we gonna need for this?

27
00:01:07,810 --> 00:01:09,530
‫We will need mongoose of course

28
00:01:09,530 --> 00:01:11,370
‫so let's start with that.

29
00:01:11,370 --> 00:01:15,380
‫Or actually, let's just go ahead into the server.js file

30
00:01:15,380 --> 00:01:16,990
‫and copy this stuff

31
00:01:16,990 --> 00:01:20,053
‫because why writing it all over again.

32
00:01:20,960 --> 00:01:23,320
‫So let's copy everything

33
00:01:23,320 --> 00:01:26,090
‫and then delete what we don't need.

34
00:01:26,090 --> 00:01:28,410
‫So we don't need our express application

35
00:01:29,370 --> 00:01:31,370
‫we also need the .env package

36
00:01:31,370 --> 00:01:33,740
‫because we need our environment variables

37
00:01:33,740 --> 00:01:38,740
‫in order to be able to connect to the database again, okay.

38
00:01:38,970 --> 00:01:41,560
‫And we need to connect to the database in this script

39
00:01:41,560 --> 00:01:44,220
‫again because it runs completely independent

40
00:01:44,220 --> 00:01:46,010
‫from the express application.

41
00:01:46,010 --> 00:01:48,930
‫It's only gonna run once in the beginning.

42
00:01:48,930 --> 00:01:52,690
‫Next up, we need access to the file system module

43
00:01:52,690 --> 00:01:55,483
‫because of course we want to read the JSON file.

44
00:01:57,100 --> 00:01:58,700
‫So require fs

45
00:01:59,910 --> 00:02:03,860
‫and finally we also need access to the tour model

46
00:02:03,860 --> 00:02:05,390
‫because the tour model is

47
00:02:05,390 --> 00:02:08,993
‫where we want to write the tours to, right?

48
00:02:10,300 --> 00:02:12,560
‫So, tour equals

49
00:02:12,560 --> 00:02:14,870
‫and now let's find the path there

50
00:02:15,900 --> 00:02:18,410
‫so from the place where we are right now

51
00:02:18,410 --> 00:02:21,190
‫we need to go up one level.

52
00:02:21,190 --> 00:02:24,023
‫And what's going on here with these quotes?

53
00:02:25,800 --> 00:02:27,640
‫All right, so one level up

54
00:02:27,640 --> 00:02:29,960
‫and we're in dev data.

55
00:02:29,960 --> 00:02:32,250
‫So we need another level up

56
00:02:32,250 --> 00:02:33,900
‫so that we're in the main folder.

57
00:02:33,900 --> 00:02:36,810
‫And from there we go in to models

58
00:02:36,810 --> 00:02:38,483
‫and into the tour model.

59
00:02:39,910 --> 00:02:43,160
‫Okay and that should be it for setup.

60
00:02:43,160 --> 00:02:46,053
‫Now let's start by reading the file.

61
00:02:47,340 --> 00:02:50,460
‫So, read JSON file

62
00:02:50,460 --> 00:02:52,253
‫and that should be fairly simple.

63
00:02:54,250 --> 00:02:57,490
‫So the tours are at fs.readfile

64
00:02:59,250 --> 00:03:01,700
‫and we can use the synchronous version of course.

65
00:03:02,820 --> 00:03:07,633
‫And let's simply say tours simple.json, okay.

66
00:03:08,467 --> 00:03:09,403
‫And then,

67
00:03:10,260 --> 00:03:12,970
‫also the encoding.

68
00:03:12,970 --> 00:03:15,233
‫So, file encoding, utf eight.

69
00:03:16,600 --> 00:03:17,563
‫Give it a save.

70
00:03:18,730 --> 00:03:21,540
‫And so now we can write the actual function

71
00:03:21,540 --> 00:03:24,393
‫that is gonna import the data into the database.

72
00:03:25,750 --> 00:03:29,183
‫So import data into database.

73
00:03:30,040 --> 00:03:32,380
‫Okay, just like this.

74
00:03:32,380 --> 00:03:33,940
‫And so let's create this function.

75
00:03:33,940 --> 00:03:37,690
‫Import data, import data,

76
00:03:37,690 --> 00:03:39,000
‫yep.

77
00:03:39,000 --> 00:03:40,980
‫And that's gonna be and async function

78
00:03:43,010 --> 00:03:45,940
‫which does not need any arguments

79
00:03:45,940 --> 00:03:50,913
‫and so let's again use a try catch block here.

80
00:03:53,902 --> 00:03:57,520
‫And here I'm simply gonna log it to the console

81
00:03:57,520 --> 00:03:58,740
‫if there is some error,

82
00:03:58,740 --> 00:04:02,350
‫just to know what's going on in that case.

83
00:04:02,350 --> 00:04:03,183
‫And now here,

84
00:04:03,183 --> 00:04:05,900
‫what we will do is very simple.

85
00:04:05,900 --> 00:04:07,253
‫We are simply gonna await,

86
00:04:08,100 --> 00:04:10,950
‫tour.create.

87
00:04:10,950 --> 00:04:13,200
‫So we already used tour.create

88
00:04:13,200 --> 00:04:16,070
‫and we pass then an object back then right?

89
00:04:16,070 --> 00:04:20,930
‫But the create method can also accept an array of objects.

90
00:04:20,930 --> 00:04:22,010
‫And in that case

91
00:04:22,010 --> 00:04:24,390
‫it will then simply create a new document

92
00:04:24,390 --> 00:04:26,663
‫for each of the objects in the array.

93
00:04:27,560 --> 00:04:28,920
‫So, very simple,

94
00:04:28,920 --> 00:04:33,920
‫all we have to do is to specify our tours data here, right?

95
00:04:34,750 --> 00:04:37,520
‫And actually it's not 100% correct

96
00:04:37,520 --> 00:04:40,280
‫because remember that this is JSON.

97
00:04:40,280 --> 00:04:42,860
‫And so we need to first convert it actually

98
00:04:42,860 --> 00:04:47,423
‫into a JavaScript object using json.parse.

99
00:04:49,580 --> 00:04:52,380
‫Okay and so now we actually have

100
00:04:52,380 --> 00:04:54,480
‫an array of JavaScript objects

101
00:04:54,480 --> 00:04:59,220
‫that we can now pass into the create method, okay.

102
00:04:59,220 --> 00:05:00,950
‫And if that was successful,

103
00:05:00,950 --> 00:05:03,290
‫then the next line is gonna be executed

104
00:05:04,350 --> 00:05:08,660
‫and so here we can say data successfully

105
00:05:10,820 --> 00:05:12,910
‫loaded, all right.

106
00:05:12,910 --> 00:05:15,060
‫And this should already do the job.

107
00:05:15,060 --> 00:05:19,300
‫Now what about the data that is already in the database?

108
00:05:19,300 --> 00:05:21,150
‫We can also create an easy way

109
00:05:21,150 --> 00:05:24,620
‫to basically delete all of that data at the same time.

110
00:05:24,620 --> 00:05:27,343
‫And so let's simply go ahead and do that as well.

111
00:05:28,250 --> 00:05:30,750
‫So, delete all data

112
00:05:31,762 --> 00:05:33,823
‫from collection, let's say.

113
00:05:35,260 --> 00:05:37,840
‫And this weird yellow color that you see here

114
00:05:37,840 --> 00:05:41,070
‫actually comes from an extension that I have installed here.

115
00:05:41,070 --> 00:05:42,820
‫And so to get rid of that,

116
00:05:42,820 --> 00:05:45,633
‫I'm simply gonna write database again, okay.

117
00:05:47,610 --> 00:05:49,110
‫So delete data

118
00:05:50,460 --> 00:05:53,910
‫and again this is gonna be an async function

119
00:05:53,910 --> 00:05:55,373
‫without any arguments.

120
00:05:57,640 --> 00:05:59,880
‫And let me actually copy this code here.

121
00:06:01,885 --> 00:06:03,170
‫So, delete it

122
00:06:05,000 --> 00:06:07,520
‫and now about the deleting itself

123
00:06:07,520 --> 00:06:11,820
‫we can use the delete many function.

124
00:06:11,820 --> 00:06:14,240
‫Okay and actually I showed you this one

125
00:06:14,240 --> 00:06:18,120
‫back in the intro to MongoDB, right?

126
00:06:18,120 --> 00:06:19,920
‫Where we could use delete many

127
00:06:19,920 --> 00:06:22,610
‫and then simply pass in nothing in there

128
00:06:22,610 --> 00:06:23,640
‫and that would then delete

129
00:06:23,640 --> 00:06:26,710
‫all of the documents in a certain collection, right?

130
00:06:26,710 --> 00:06:29,020
‫And so mongoose basically implemented

131
00:06:29,020 --> 00:06:33,180
‫the same function here on the model, okay.

132
00:06:33,180 --> 00:06:34,013
‫So in this case,

133
00:06:34,013 --> 00:06:37,520
‫the tour model has access to this delete many method

134
00:06:37,520 --> 00:06:39,120
‫which will then do exactly the same

135
00:06:39,120 --> 00:06:43,380
‫as delete many does in native MongoDB, right?

136
00:06:43,380 --> 00:06:46,320
‫So, remember that mongoose is just a,

137
00:06:46,320 --> 00:06:49,740
‫like a layer of abstraction on top of MongoDB.

138
00:06:49,740 --> 00:06:52,700
‫Which is why it doesn't use the exact same functions

139
00:06:52,700 --> 00:06:56,040
‫but it still gives us access to some similar ones

140
00:06:56,040 --> 00:06:58,490
‫or to ones that actually have the same name.

141
00:06:58,490 --> 00:07:00,570
‫So delete many actually has the same name

142
00:07:00,570 --> 00:07:03,780
‫as the native MongoDB function, all right?

143
00:07:03,780 --> 00:07:06,700
‫So again, what this is gonna do is to simply go ahead

144
00:07:06,700 --> 00:07:10,620
‫and delete all the documents in the tours collection.

145
00:07:10,620 --> 00:07:12,860
‫So, we have our two functions here

146
00:07:12,860 --> 00:07:15,240
‫but if we now actually run this file

147
00:07:15,240 --> 00:07:16,850
‫then nothing will happen.

148
00:07:16,850 --> 00:07:17,700
‫And that's because

149
00:07:17,700 --> 00:07:21,320
‫we're not calling any of these functions anywhere, right?

150
00:07:21,320 --> 00:07:22,300
‫Now we could go ahead

151
00:07:22,300 --> 00:07:26,820
‫and simply write something like import data here

152
00:07:26,820 --> 00:07:29,000
‫and then simply call the function here

153
00:07:29,000 --> 00:07:32,040
‫but I wanted to make this a little bit more fun.

154
00:07:32,040 --> 00:07:34,930
‫So let's now actually learn a tiny little bit

155
00:07:34,930 --> 00:07:38,130
‫about interacting with the command line, okay.

156
00:07:38,130 --> 00:07:39,580
‫And so I'm actually gonna go ahead

157
00:07:39,580 --> 00:07:43,480
‫and run this file without calling any of these functions.

158
00:07:43,480 --> 00:07:45,480
‫But instead I'm gonna log to the console

159
00:07:47,260 --> 00:07:51,310
‫process.argv,

160
00:07:51,310 --> 00:07:52,143
‫okay.

161
00:07:52,143 --> 00:07:55,800
‫Just so we can see what process.argv actually is

162
00:07:55,800 --> 00:07:57,860
‫so that we can then use it.

163
00:07:57,860 --> 00:07:58,693
‫All right.

164
00:07:58,693 --> 00:08:01,080
‫Let me open up here another terminal

165
00:08:01,080 --> 00:08:02,583
‫and then I will use node,

166
00:08:03,840 --> 00:08:05,520
‫go into dev data

167
00:08:05,520 --> 00:08:06,353
‫then into data

168
00:08:06,353 --> 00:08:08,980
‫and then in there import dev data.

169
00:08:08,980 --> 00:08:11,570
‫And we get some errors here.

170
00:08:11,570 --> 00:08:12,560
‫Let's see where.

171
00:08:12,560 --> 00:08:15,710
‫Ah, yeah so it's because of this,

172
00:08:15,710 --> 00:08:17,290
‫of this file name.

173
00:08:17,290 --> 00:08:20,963
‫So I guess we should specify the path to there basically.

174
00:08:22,020 --> 00:08:24,540
‫So let's run this one again

175
00:08:24,540 --> 00:08:26,710
‫and again we have this error.

176
00:08:26,710 --> 00:08:30,010
‫And yeah, of course I get this error.

177
00:08:30,010 --> 00:08:31,360
‫That's a stupid one.

178
00:08:31,360 --> 00:08:32,860
‫Remember how I told you

179
00:08:32,860 --> 00:08:36,710
‫that this dot here is always relative from the folder

180
00:08:36,710 --> 00:08:39,210
‫where the node application was actually started.

181
00:08:39,210 --> 00:08:40,670
‫And so that's the home folder.

182
00:08:40,670 --> 00:08:42,740
‫And so we're basically looking for this file here

183
00:08:42,740 --> 00:08:45,010
‫in the home folder, okay.

184
00:08:45,010 --> 00:08:49,470
‫So what I should use instead is the dir name,

185
00:08:49,470 --> 00:08:52,860
‫variable that is available to us everywhere.

186
00:08:52,860 --> 00:08:54,653
‫So that goes like this.

187
00:08:58,980 --> 00:09:00,320
‫All right.

188
00:09:00,320 --> 00:09:01,810
‫Give it another save

189
00:09:01,810 --> 00:09:05,860
‫and clear up the console and run it again.

190
00:09:05,860 --> 00:09:07,080
‫And so now it works.

191
00:09:07,080 --> 00:09:08,000
‫And so here

192
00:09:08,000 --> 00:09:11,650
‫is the result of this console.log that we have down here,

193
00:09:11,650 --> 00:09:12,897
‫So process.argv

194
00:09:14,020 --> 00:09:16,020
‫and basically that is an array

195
00:09:16,020 --> 00:09:20,880
‫of these two arguments of running this node process.

196
00:09:20,880 --> 00:09:22,890
‫So, this here is basically

197
00:09:22,890 --> 00:09:24,930
‫where the node command is located.

198
00:09:24,930 --> 00:09:26,910
‫So this equivalent to this node

199
00:09:26,910 --> 00:09:28,940
‫and then the second one,

200
00:09:28,940 --> 00:09:33,730
‫so this path to this file is actually this here, okay.

201
00:09:33,730 --> 00:09:35,490
‫So let's quit this here

202
00:09:35,490 --> 00:09:37,723
‫and let's add kind of an option here.

203
00:09:39,130 --> 00:09:40,090
‫So I'm gonna write,

204
00:09:40,090 --> 00:09:41,750
‫dash, dash import

205
00:09:41,750 --> 00:09:43,620
‫and so I'm sure you have seen something like this

206
00:09:43,620 --> 00:09:44,910
‫many times before.

207
00:09:44,910 --> 00:09:47,930
‫For example, when we save a package as a dev dependency

208
00:09:47,930 --> 00:09:49,763
‫we do it like this.

209
00:09:50,950 --> 00:09:53,180
‫Save dev, and so we use the same

210
00:09:53,180 --> 00:09:55,710
‫kind of format for specifying options.

211
00:09:55,710 --> 00:09:57,200
‫Okay so, dash dash

212
00:09:57,200 --> 00:09:59,760
‫and then whatever string we put here.

213
00:09:59,760 --> 00:10:03,187
‫And so I choose to basically specify

214
00:10:03,187 --> 00:10:05,260
‫the import option like this.

215
00:10:05,260 --> 00:10:07,354
‫And so you see that now the third argument

216
00:10:07,354 --> 00:10:10,660
‫is dash dash import, all right?

217
00:10:10,660 --> 00:10:12,860
‫And so that means that we can now go ahead

218
00:10:12,860 --> 00:10:15,460
‫and basically use this data here

219
00:10:15,460 --> 00:10:16,410
‫in order to write

220
00:10:16,410 --> 00:10:19,900
‫a very simple command line application basically

221
00:10:19,900 --> 00:10:22,970
‫which will import the data when we specify this option

222
00:10:22,970 --> 00:10:24,430
‫and will delete the data

223
00:10:24,430 --> 00:10:27,223
‫when we specify the delete option, all right?

224
00:10:28,090 --> 00:10:29,983
‫So, let's actually do that.

225
00:10:32,090 --> 00:10:33,240
‫So, if

226
00:10:34,140 --> 00:10:37,090
‫process.argv

227
00:10:37,090 --> 00:10:38,040
‫and it's an array

228
00:10:38,040 --> 00:10:40,370
‫and we want the third.

229
00:10:40,370 --> 00:10:42,423
‫So zero, one, two.

230
00:10:44,610 --> 00:10:49,300
‫So if that element is equal to import

231
00:10:50,380 --> 00:10:54,313
‫well, then we want to run import data.

232
00:10:55,860 --> 00:10:56,693
‫Right?

233
00:10:58,950 --> 00:10:59,783
‫If...

234
00:11:00,790 --> 00:11:04,320
‫Process.argv two

235
00:11:04,320 --> 00:11:05,853
‫is equal,

236
00:11:09,180 --> 00:11:12,150
‫to delete then we want to run

237
00:11:15,310 --> 00:11:16,810
‫delete data.

238
00:11:16,810 --> 00:11:17,643
‫And that's it.

239
00:11:19,240 --> 00:11:21,270
‫So, that should actually give us

240
00:11:21,270 --> 00:11:23,890
‫the result that we're looking for.

241
00:11:23,890 --> 00:11:25,580
‫Let's finish this here.

242
00:11:25,580 --> 00:11:27,540
‫And so now let's run the command here

243
00:11:27,540 --> 00:11:30,460
‫with delete in order to delete all the data

244
00:11:30,460 --> 00:11:32,240
‫that we have in the database.

245
00:11:32,240 --> 00:11:33,413
‫So let's try that out.

246
00:11:35,120 --> 00:11:36,560
‫It's doing something

247
00:11:36,560 --> 00:11:38,813
‫and data successfully deleted.

248
00:11:39,770 --> 00:11:42,160
‫So let's take a look at that now.

249
00:11:42,160 --> 00:11:46,110
‫And if we run now this get all tours route

250
00:11:46,110 --> 00:11:49,390
‫then indeed we have zero results.

251
00:11:49,390 --> 00:11:52,380
‫So, all our tours are now gone.

252
00:11:52,380 --> 00:11:54,020
‫So it worked.

253
00:11:54,020 --> 00:11:57,380
‫Now this process here is basically still running.

254
00:11:57,380 --> 00:11:59,060
‫And so let's quickly fix that,

255
00:11:59,060 --> 00:12:01,210
‫which is kind of easy.

256
00:12:01,210 --> 00:12:03,410
‫So, that's a new one we haven't used yet.

257
00:12:03,410 --> 00:12:07,480
‫Which is process.exit,

258
00:12:07,480 --> 00:12:08,520
‫All right?

259
00:12:08,520 --> 00:12:12,290
‫Now this process.exit is kind of an aggressive way

260
00:12:12,290 --> 00:12:14,120
‫of stopping an application

261
00:12:14,120 --> 00:12:16,280
‫but in this case it's no problem

262
00:12:16,280 --> 00:12:19,060
‫because it's really just a very small script

263
00:12:19,060 --> 00:12:23,210
‫that we're running here and not a real application, right?

264
00:12:23,210 --> 00:12:24,790
‫Let's just copy the same thing here

265
00:12:24,790 --> 00:12:26,683
‫into our import data function.

266
00:12:27,860 --> 00:12:29,483
‫And so now I'm gonna quit it.

267
00:12:30,350 --> 00:12:32,230
‫And just to show that it works

268
00:12:32,230 --> 00:12:33,330
‫I'm gonna run it again

269
00:12:34,620 --> 00:12:36,080
‫so data successfully deleted

270
00:12:36,080 --> 00:12:38,513
‫and then it exited the process.

271
00:12:39,530 --> 00:12:40,520
‫All right.

272
00:12:40,520 --> 00:12:43,943
‫And so now it's time to actually run the function

273
00:12:43,943 --> 00:12:46,293
‫that we were interested in in the first place.

274
00:12:47,650 --> 00:12:50,760
‫So with the import flag, basically.

275
00:12:50,760 --> 00:12:52,380
‫So the import option.

276
00:12:52,380 --> 00:12:53,647
‫So let's run that

277
00:12:53,647 --> 00:12:56,210
‫and let's see if it actually works.

278
00:12:56,210 --> 00:12:57,720
‫And it didn't.

279
00:12:57,720 --> 00:12:59,343
‫So why is that?

280
00:13:00,220 --> 00:13:03,823
‫So it tells us here a tour must have a group size.

281
00:13:05,060 --> 00:13:07,790
‫So where's that coming from?

282
00:13:07,790 --> 00:13:10,400
‫And we see a lot of validation errors here.

283
00:13:10,400 --> 00:13:13,023
‫So something must have gone wrong here.

284
00:13:14,370 --> 00:13:15,750
‫So yeah, we have the cover image,

285
00:13:15,750 --> 00:13:20,110
‫we have the tour description.

286
00:13:20,110 --> 00:13:21,663
‫We have the price.

287
00:13:22,610 --> 00:13:23,540
‫Well, that's weird.

288
00:13:23,540 --> 00:13:24,823
‫Max group size,

289
00:13:26,760 --> 00:13:29,653
‫let me actually check if anything happened here.

290
00:13:30,620 --> 00:13:32,120
‫Actually we have nine tours here

291
00:13:32,120 --> 00:13:35,120
‫and I think nine is actually all we have.

292
00:13:35,120 --> 00:13:39,380
‫And so to me it kind of looks like it actually did work.

293
00:13:39,380 --> 00:13:43,570
‫But let's actually take a quick look at our data here.

294
00:13:43,570 --> 00:13:47,603
‫So, just to figure out why this actually happens.

295
00:13:48,730 --> 00:13:52,040
‫So tour simple here

296
00:13:52,040 --> 00:13:53,620
‫and so we can already see,

297
00:13:53,620 --> 00:13:57,180
‫actually the problem that is happening.

298
00:13:57,180 --> 00:13:58,840
‫So we have all these tours

299
00:13:58,840 --> 00:14:00,730
‫so the original ones.

300
00:14:00,730 --> 00:14:02,630
‫But then from the last section,

301
00:14:02,630 --> 00:14:04,170
‫we have these three here

302
00:14:04,170 --> 00:14:08,160
‫that we kind of added using our file based API.

303
00:14:08,160 --> 00:14:09,210
‫So, remember that?

304
00:14:09,210 --> 00:14:12,120
‫So back then we only specified the name, duration

305
00:14:12,120 --> 00:14:14,660
‫and difficulty and nothing else.

306
00:14:14,660 --> 00:14:16,030
‫And so right now

307
00:14:16,030 --> 00:14:19,920
‫our script is trying to import these three tours.

308
00:14:19,920 --> 00:14:23,010
‫But of course, we're not interested in them at all

309
00:14:23,010 --> 00:14:28,010
‫and so let's go ahead and save this here, okay.

310
00:14:28,030 --> 00:14:29,620
‫Then quit this process

311
00:14:29,620 --> 00:14:32,720
‫and so actually this process.exit

312
00:14:32,720 --> 00:14:35,650
‫can be outside of the try catch block

313
00:14:35,650 --> 00:14:36,497
‫and be simply here by the end of the function.

314
00:14:36,497 --> 00:14:37,961
‫So that no matter if there's an error or not

315
00:14:37,961 --> 00:14:42,583
‫it will always just exit the process.

316
00:14:43,980 --> 00:14:44,813
‫All right.

317
00:14:45,900 --> 00:14:47,543
‫So let's delete everything.

318
00:14:49,580 --> 00:14:51,820
‫All right, clear the console again.

319
00:14:51,820 --> 00:14:52,893
‫Now import,

320
00:14:54,230 --> 00:14:55,063
‫and yeah.

321
00:14:55,063 --> 00:14:56,853
‫So data successfully loaded.

322
00:14:59,790 --> 00:15:02,180
‫As indeed here we are again.

323
00:15:02,180 --> 00:15:04,210
‫So now it's working 100%,

324
00:15:04,210 --> 00:15:08,020
‫we have our data that we can start working with now

325
00:15:08,020 --> 00:15:09,800
‫and so, yeah.

326
00:15:09,800 --> 00:15:12,740
‫Our work with this one here is done.

327
00:15:12,740 --> 00:15:14,900
‫So, a nice little function,

328
00:15:14,900 --> 00:15:16,310
‫or a nice little script actually.

329
00:15:16,310 --> 00:15:20,200
‫I hope that everything made sense to you

330
00:15:20,200 --> 00:15:25,200
‫and yeah that it was kind of a fun exercise for you as well.

331
00:15:25,320 --> 00:15:26,970
‫Anyway, see you in the next video

332
00:15:26,970 --> 00:15:31,090
‫where we are finally starting to then use all this data

333
00:15:31,090 --> 00:15:32,740
‫and to improve our API

334
00:15:32,740 --> 00:15:35,203
‫{\an8}by implementing a couple of nice features.

