1
00:00:00,020 --> 00:00:00,380
All right.

2
00:00:00,380 --> 00:00:03,570
And up next, let's set up structure for our data.

3
00:00:03,590 --> 00:00:08,000
So essentially in this application, we will be creating jobs.

4
00:00:08,029 --> 00:00:08,720
Correct.

5
00:00:08,990 --> 00:00:16,490
And each job is going to have position company where it's located as well as job status and job type.

6
00:00:16,640 --> 00:00:25,760
And in order to set up the structure first, we'll need to create a models folder since there's going

7
00:00:25,760 --> 00:00:27,350
to be multiple models.

8
00:00:27,380 --> 00:00:29,120
And we'll start with the job model.

9
00:00:29,150 --> 00:00:33,110
So in here, let's create a new file and let's go with Job.

10
00:00:34,020 --> 00:00:34,620
Model.

11
00:00:34,620 --> 00:00:35,470
JS.

12
00:00:35,490 --> 00:00:38,370
First we want to grab the mongoose.

13
00:00:39,150 --> 00:00:40,260
So same deal.

14
00:00:41,390 --> 00:00:44,780
Effectively we import mongoose from Mongoose.

15
00:00:44,900 --> 00:00:47,310
Then let's create a schema.

16
00:00:47,330 --> 00:00:49,190
So first we need to come up with a name.

17
00:00:49,190 --> 00:00:56,510
In my case, it's going to be job schema and eventually there's also going to be a user schema and eventually

18
00:00:56,510 --> 00:01:03,530
we'll connect it to since each job belongs to a specific user and we want to go with new Mongoose and

19
00:01:03,530 --> 00:01:04,730
then schema.

20
00:01:04,879 --> 00:01:06,650
So that's the name.

21
00:01:06,650 --> 00:01:11,540
And then inside of the schema we want to pass in the object.

22
00:01:11,540 --> 00:01:17,390
And then one by one we'll set up the properties just like we do in normal JavaScript object.

23
00:01:17,420 --> 00:01:24,860
Of course, in this case we're just setting up the properties for our database instance and we'll start

24
00:01:24,860 --> 00:01:26,030
here with a simple one.

25
00:01:26,030 --> 00:01:28,700
So I'm going to go with Company String now.

26
00:01:29,280 --> 00:01:34,350
Of course there are multiple value types, but I'm not going to cover each and every option over here

27
00:01:34,350 --> 00:01:35,250
for the type.

28
00:01:36,100 --> 00:01:40,060
Basically, as we're working on a project, you'll see some other options as well.

29
00:01:40,060 --> 00:01:41,320
So company string.

30
00:01:41,350 --> 00:01:42,690
Pretty straightforward.

31
00:01:42,700 --> 00:01:45,460
So the same thing we want to do with position.

32
00:01:45,820 --> 00:01:49,600
So that's going to be my second property over here.

33
00:01:49,690 --> 00:01:58,710
Then if we have more complex setup, we can create a key as a object.

34
00:01:58,720 --> 00:01:59,650
What am I talking about?

35
00:01:59,650 --> 00:02:02,050
Well, let's say for job status.

36
00:02:02,170 --> 00:02:05,410
Notice over here how we have these three values.

37
00:02:05,410 --> 00:02:09,000
So it might be pending interview or declined.

38
00:02:09,009 --> 00:02:15,970
So instead of just setting it equal to string number or whatever, I'm going to go with job status,

39
00:02:16,150 --> 00:02:18,220
then I'll create an object.

40
00:02:18,220 --> 00:02:20,170
And first, what is going to be the type?

41
00:02:20,170 --> 00:02:21,310
Well, same deal.

42
00:02:21,310 --> 00:02:22,600
It's going to be string.

43
00:02:22,640 --> 00:02:31,900
Then we're going to go with enum and essentially enum data type represents a field with predefined set

44
00:02:31,900 --> 00:02:33,730
of values like you just saw.

45
00:02:33,760 --> 00:02:40,250
There's a select box on the front end which allows to have interview declined and pending and in here

46
00:02:40,250 --> 00:02:41,210
we go with enum.

47
00:02:42,060 --> 00:02:43,610
And we provide those values.

48
00:02:43,620 --> 00:02:46,830
So essentially it will send a value that doesn't match anything.

49
00:02:46,830 --> 00:02:51,030
What we have here in the array, mongoose is just going to yell at us.

50
00:02:51,870 --> 00:02:54,150
And we won't be able to submit the job.

51
00:02:54,840 --> 00:02:56,530
Well, then we want to go with declined.

52
00:02:56,530 --> 00:03:01,990
And as a side note, eventually we will set them up as constants, but not for now.

53
00:03:02,840 --> 00:03:04,750
Let's go here with pending as well.

54
00:03:06,520 --> 00:03:09,310
And then we also can set up the default value.

55
00:03:10,340 --> 00:03:12,680
And we just provide the default property.

56
00:03:13,060 --> 00:03:15,350
In my case, I'm going to go with pending here.

57
00:03:15,560 --> 00:03:16,220
Let's save it.

58
00:03:16,250 --> 00:03:17,930
Now we have the job status.

59
00:03:17,960 --> 00:03:24,260
Now the job type also is going to be no, because again, we have this select box with these values.

60
00:03:24,260 --> 00:03:25,490
And therefore.

61
00:03:26,210 --> 00:03:29,420
Basically we just want to copy this, so copy and paste.

62
00:03:30,580 --> 00:03:33,600
Let's change the value around instead of job.

63
00:03:34,390 --> 00:03:39,520
Status is going to be job type, still string, but these values are going to be different.

64
00:03:39,520 --> 00:03:41,560
So here we're looking for full time.

65
00:03:42,800 --> 00:03:43,940
Then part time.

66
00:03:46,120 --> 00:03:48,790
Part time and an internship.

67
00:03:52,030 --> 00:03:53,770
And as far as the default one.

68
00:03:54,950 --> 00:03:56,600
I think I'm just going to go with full time.

69
00:03:57,350 --> 00:04:03,980
Then we also have job location, which essentially just represents where the job is located.

70
00:04:04,100 --> 00:04:10,330
And as far as the front end, we will use the user's location in order to provide the value.

71
00:04:10,340 --> 00:04:17,300
But when it comes to our database, basically we just want to provide type string.

72
00:04:17,300 --> 00:04:22,850
So it's going to be a string and default value just in case it's not provided.

73
00:04:22,940 --> 00:04:25,190
We're going to go here with my city.

74
00:04:25,190 --> 00:04:33,050
So we have the schema and before we set up the model, essentially our collection right after the first

75
00:04:33,050 --> 00:04:36,500
object, we want to make a comma and another one.

76
00:04:36,500 --> 00:04:41,120
And here we just want to go with timestamps and set it equal to true.

77
00:04:41,150 --> 00:04:48,620
So if we add this property with this value, essentially whenever we will create the instance, not

78
00:04:48,620 --> 00:04:57,840
only will get the IDs which MongoDB sets up by default, but we'll also have this createdat and Updatedat

79
00:04:57,840 --> 00:05:05,010
fields and pretty much every time we'll do something with our instance, we'll get the correct values,

80
00:05:05,010 --> 00:05:08,430
something we'll cover a little bit later, but very, very nifty.

81
00:05:09,170 --> 00:05:13,430
And also we want to export this, so we're going to go with export default.

82
00:05:15,060 --> 00:05:16,530
Then mongoose.

83
00:05:16,530 --> 00:05:22,920
So our instance then model and this is where we need to create a name for our model.

84
00:05:22,950 --> 00:05:29,200
Effectively we're creating a collection and whenever you hear a word collection, think table.

85
00:05:29,220 --> 00:05:33,090
So this is where we'll group all of our instances.

86
00:05:33,090 --> 00:05:38,160
And in my case, I'm going to go with Job and we want to provide the job schema.

87
00:05:38,280 --> 00:05:39,810
We'll save this over here.

88
00:05:39,930 --> 00:05:43,260
And up next, we'll work on create job Controller.

89
00:05:43,320 --> 00:05:47,730
Only in this case, we will save the job in a database.

