1
00:00:00,270 --> 00:00:00,630
All right.

2
00:00:00,990 --> 00:00:09,060
And once we have market data in the road, let's populate the database and we're going to do that first

3
00:00:09,060 --> 00:00:16,800
will create populate jobs in the world very much right next through the mock data online, since it's

4
00:00:16,800 --> 00:00:18,210
going to be a separate file.

5
00:00:18,780 --> 00:00:22,140
So we're not going to run that inside of these server jobs.

6
00:00:22,560 --> 00:00:24,060
We'll have to repeat some steps.

7
00:00:24,510 --> 00:00:30,120
We'll have to connect to the database and remember our Connect DB function is looking for process,

8
00:00:30,120 --> 00:00:32,460
not envy and then among all URL.

9
00:00:32,700 --> 00:00:38,880
And therefore we'll need to import the data and repackage as well, just like we did in a server.

10
00:00:39,330 --> 00:00:46,400
And then we'll also get the job and then we'll set up a star function just like we have in the server.

11
00:00:46,410 --> 00:00:50,100
And remember this one, the popular address or on separately.

12
00:00:50,790 --> 00:00:56,730
So basically, we'll stop our own server, the one that's spinning up right now, our application and

13
00:00:56,730 --> 00:00:59,640
run, and we'll just invoke the popular address.

14
00:00:59,970 --> 00:01:04,530
So a one time thing will just populate the database and then we'll move back to our project.

15
00:01:04,920 --> 00:01:10,590
Now, as far as the functionality, like I said, we use Connect DB, so connect to a database run.

16
00:01:10,600 --> 00:01:17,730
What's really nifty that on the model we have delete memory, which essentially is just going to clean

17
00:01:17,730 --> 00:01:18,810
out our database.

18
00:01:19,440 --> 00:01:21,510
And yes, it's going to remove all the jobs.

19
00:01:21,510 --> 00:01:26,880
But in our case, we don't have that many anyway when we want to grab that JSON data.

20
00:01:27,240 --> 00:01:32,100
And this is where it gets a bit tricky since we're using your six modules.

21
00:01:32,580 --> 00:01:34,920
It's not as straightforward as with common.

22
00:01:35,850 --> 00:01:40,230
If you have worked with common jazz where Jason, you know, but we simply need to import.

23
00:01:40,620 --> 00:01:47,880
In this case, we do a little bit of acrobatics where we want to grab the reed file from the file system

24
00:01:47,880 --> 00:01:48,360
module.

25
00:01:48,810 --> 00:01:52,410
More specifically, the one that returns a promise.

26
00:01:52,620 --> 00:01:56,670
Remember, by default, we get the callback one, but that's not what I want in years.

27
00:01:57,150 --> 00:01:59,940
And then we want to go with Jason Pass.

28
00:02:00,480 --> 00:02:07,540
Then we'll wait for Reed file when we need to pass in New York so that the file.

29
00:02:07,770 --> 00:02:09,690
And then we need to have this import matter.

30
00:02:09,770 --> 00:02:10,199
URL.

31
00:02:10,820 --> 00:02:16,200
Again, this important matter you are, you'll see quite often when it comes to ES6 modules, because

32
00:02:16,200 --> 00:02:21,290
again, some functionality is not as straightforward as with common dress.

33
00:02:21,840 --> 00:02:23,670
Just keep that in mind.

34
00:02:24,000 --> 00:02:30,000
And then once we have our JSON product, what are we can do with job create?

35
00:02:30,330 --> 00:02:37,020
Instead of just passing in one job, we can pass in the array and then automatically all of those jobs

36
00:02:37,020 --> 00:02:43,380
will be out of when we go with console.log success just so we know that everything works and we go with

37
00:02:43,380 --> 00:02:45,930
process, exit and zero.

38
00:02:46,170 --> 00:02:47,610
Now this is totally optional.

39
00:02:47,940 --> 00:02:49,530
This is just to showcase that in node.

40
00:02:49,530 --> 00:02:56,250
If you ever want to exit the program, meaning the process you can go with process, exit and then zero

41
00:02:56,250 --> 00:02:58,530
means that everything went fine.

42
00:02:58,830 --> 00:03:00,540
Basically, we're successfully exiting.

43
00:03:01,080 --> 00:03:09,180
Or if there is an error which is going to be in the cache case, then we just log the error first and

44
00:03:09,180 --> 00:03:11,940
we exit with the value of one.

45
00:03:12,720 --> 00:03:14,670
So let's start cracking on that one.

46
00:03:15,030 --> 00:03:19,560
And then let's go here, either route or go to populate.

47
00:03:20,480 --> 00:03:23,300
And yes, Ron, first.

48
00:03:24,360 --> 00:03:26,040
Let's grab the Reid file, I guess.

49
00:03:26,520 --> 00:03:32,250
Import Reid File A. I know this is going to be for pretty much any duration that you want.

50
00:03:32,520 --> 00:03:33,880
You have multiple approaches.

51
00:03:33,900 --> 00:03:37,640
There's another one where you can convert the requirement.

52
00:03:37,650 --> 00:03:40,230
But I thought that this one was a bit more straightforward.

53
00:03:41,280 --> 00:03:45,800
We're going to go here with promises of that and we also want to grab the entry.

54
00:03:46,470 --> 00:03:48,180
And I'm not going to repeat why we need that.

55
00:03:48,630 --> 00:03:51,160
So we're going to go here with dot entry.

56
00:03:51,190 --> 00:03:52,110
That's the package name.

57
00:03:52,120 --> 00:03:54,900
Then remember, we need to set up our configured right away.

58
00:03:55,320 --> 00:03:56,940
So config, let's invoke it.

59
00:03:57,420 --> 00:04:04,560
And then let's grab two things the cannot be as well as the job models or import an ugly B will be my

60
00:04:04,560 --> 00:04:11,610
name, and I just need to remember that I need to be viewed as one of the ways I'll get the error and

61
00:04:11,610 --> 00:04:13,170
we'll do the same thing with a job.

62
00:04:13,320 --> 00:04:16,410
So we're looking for the models and then job.

63
00:04:16,579 --> 00:04:17,610
Yes, let's save it.

64
00:04:18,000 --> 00:04:19,019
Let's set up that function.

65
00:04:19,019 --> 00:04:23,340
So const start and it's going to be a sink.

66
00:04:24,520 --> 00:04:30,010
And we're not going to pass anything in here and let's right away and just so we don't forget about

67
00:04:30,010 --> 00:04:30,100
it.

68
00:04:30,760 --> 00:04:34,510
And then when it comes to functionality, we want to go, try and catch because there's going to be

69
00:04:34,510 --> 00:04:36,040
some synchronous actions.

70
00:04:36,430 --> 00:04:38,590
First, let's connect to the database.

71
00:04:39,490 --> 00:04:40,770
We're going to go with an ugly B.

72
00:04:41,140 --> 00:04:44,080
And then let's pass in the process about the envy.

73
00:04:44,380 --> 00:04:49,050
And then we're looking for Mongo and not underscore you, Earl.

74
00:04:49,180 --> 00:04:55,240
That's the first step when technically this is optional, but I always like to also delete all of the

75
00:04:55,240 --> 00:04:55,690
jobs.

76
00:04:56,290 --> 00:05:00,490
Basically, I like to delete those items just so I can start from scratch.

77
00:05:00,760 --> 00:05:04,510
And therefore, I'm going to go delete many and this will remove all of the jobs.

78
00:05:04,930 --> 00:05:05,290
One.

79
00:05:05,290 --> 00:05:09,820
Let's grab those JSON products so pranced name is really up to you.

80
00:05:09,820 --> 00:05:14,670
But in my case, I'm going to go with products and that is equal to Jason.

81
00:05:14,980 --> 00:05:16,540
Ron, let's pass it right away.

82
00:05:17,110 --> 00:05:17,570
Pass.

83
00:05:17,650 --> 00:05:23,560
And then let's pass in those values where I'm going to go with a weight, then read while.

84
00:05:24,160 --> 00:05:27,700
So that's the functionality I'm importing here on the top.

85
00:05:28,060 --> 00:05:30,210
And then let's pass in a few things.

86
00:05:30,220 --> 00:05:37,210
First, we want to pass in that new URL and we need to say where the file is located.

87
00:05:37,660 --> 00:05:43,570
So in our case, and that is going to be mark data, Andreas, and the second value is going to be import

88
00:05:44,170 --> 00:05:44,760
matter.

89
00:05:45,730 --> 00:05:49,360
And then, Dr. Earl, again, that's just the syntax that you need to use.

90
00:05:49,690 --> 00:05:55,570
And once I have those JSON products, this is where I want to go with a weight job and then create and

91
00:05:55,570 --> 00:06:02,590
like I said, what's really nifty that I can pass in my entire array and effectively I'll create those

92
00:06:02,590 --> 00:06:03,010
jobs?

93
00:06:03,010 --> 00:06:07,840
And not only that, I'll tie them right away to the John, let's say here success.

94
00:06:08,770 --> 00:06:14,770
Just so we know that everything works and again optionally, we can go with process against it.

95
00:06:15,430 --> 00:06:17,290
And I'm going to set it up as a zero.

96
00:06:17,770 --> 00:06:24,580
Now let me copy this one just so I can speak up and instead of success, I want to see the error.

97
00:06:24,850 --> 00:06:32,350
If there is wrong and also go with one hour of me double check, usually the file extensions are my

98
00:06:32,350 --> 00:06:33,190
biggest issue.

99
00:06:33,190 --> 00:06:34,900
And yep, right here.

100
00:06:35,080 --> 00:06:36,700
It's not jazz.

101
00:06:36,700 --> 00:06:37,930
It is actually Jason.

102
00:06:38,350 --> 00:06:39,990
So let me save this one.

103
00:06:40,000 --> 00:06:49,360
I want to stop my current server and we want to go with the node and you're going to passengers or you

104
00:06:49,360 --> 00:06:50,920
can run node popular.

105
00:06:50,930 --> 00:06:51,880
It doesn't really matter.

106
00:06:52,090 --> 00:06:54,640
In this case, file extension is also optional.

107
00:06:55,060 --> 00:06:56,080
And check it out.

108
00:06:56,080 --> 00:06:57,370
We have success.

109
00:06:57,370 --> 00:07:05,380
So now if I move to my database and take a look, are I should have 75 jobs.

110
00:07:05,380 --> 00:07:06,370
So let me go here.

111
00:07:06,820 --> 00:07:08,020
Let me refresh.

112
00:07:09,060 --> 00:07:14,810
And if everything is correct, yep, I am seventy five total document.

113
00:07:15,240 --> 00:07:19,740
So now and also we can do is to move back where everything.

114
00:07:20,750 --> 00:07:29,510
And let's run AMPM Stark and what we should see in all jobs page, if you are logged in with that user,

115
00:07:29,510 --> 00:07:31,610
of course you should see all of them.

116
00:07:31,850 --> 00:07:36,990
So let me navigate to my current project for all jobs.

117
00:07:37,010 --> 00:07:42,770
Now we're still searching because I mean, it's going to take a little bit to spin up the server and

118
00:07:42,770 --> 00:07:43,190
everything.

119
00:07:43,190 --> 00:07:49,740
But once everything is up and running, we should see all of those 75 jobs.

120
00:07:49,760 --> 00:07:55,550
Yes, we'll set up the pagination and all of that is coming up, but we want to see the actual data.

121
00:07:55,910 --> 00:07:57,950
And once we're done loading, What do you know?

122
00:07:58,160 --> 00:08:03,500
I have all my 75 jobs and now we can start working on the stats page.

