1
00:00:00,450 --> 00:00:06,420
Once we have set up database access, network access, as well as the connections string, now let's

2
00:00:06,420 --> 00:00:13,230
actually explore the data part and we want to click on collections, then we're going to go with our

3
00:00:13,230 --> 00:00:17,580
own data and then we need to come up with a database name.

4
00:00:17,850 --> 00:00:19,650
Not the first one will be number one.

5
00:00:20,040 --> 00:00:26,220
And of course, once we connect to our application, then we'll create a task manager one.

6
00:00:26,520 --> 00:00:32,820
So the first one, I'll just call store and then they ask us to create a collection and the worry I'll

7
00:00:32,820 --> 00:00:35,520
cover what actually are collections and all that.

8
00:00:35,790 --> 00:00:41,200
But for the time being, I'm just going to go with product and we'll create one.

9
00:00:41,880 --> 00:00:47,510
And once we have everything in place, we are ready to start creating documents.

10
00:00:48,000 --> 00:00:53,070
So whenever we talk about Mongo DB, we'll have the database.

11
00:00:53,400 --> 00:00:57,800
So that essentially is going to be that application again in our case.

12
00:00:57,810 --> 00:01:01,170
Eventually this will be the task manager one.

13
00:01:02,030 --> 00:01:06,210
And then inside of that database, we'll have collections.

14
00:01:06,740 --> 00:01:11,840
Now, if you're familiar with regular databases, you can think of them as tables.

15
00:01:12,090 --> 00:01:16,820
And in our collections, we'll have a group of Mongo DB documents.

16
00:01:17,030 --> 00:01:21,140
So if I named my one product, you can probably already has that here.

17
00:01:21,140 --> 00:01:23,030
I'll have a list of products.

18
00:01:23,390 --> 00:01:30,100
And if I decide that my store will also have users, of course I can go here and create a new collection.

19
00:01:30,440 --> 00:01:33,710
And as a quick side note, we won't have to do this manually.

20
00:01:34,070 --> 00:01:36,320
I'm just showing you the general set manually.

21
00:01:36,650 --> 00:01:42,890
Of course, eventually all of this is going to happen automatically once we connect from our task manager.

22
00:01:43,160 --> 00:01:51,440
So I have a list of products and then, of course, I can also create a list of users or list of orders.

23
00:01:51,650 --> 00:01:53,530
And hopefully you get the gist.

24
00:01:53,780 --> 00:01:55,560
And once we have our list.

25
00:01:55,940 --> 00:02:02,570
Now, let's talk about the individual items so I can go to any of my collections online.

26
00:02:02,590 --> 00:02:08,060
And once I'm here, I can insert a document and document in Mongo.

27
00:02:08,060 --> 00:02:11,630
DB effectively represents that one single item.

28
00:02:11,960 --> 00:02:18,800
And what's really cool that just like JavaScript object, effectively, it's a set of key value pairs.

29
00:02:18,930 --> 00:02:25,400
Now, by default, the moment we create a new document, we'll get this underscore ID, which is going

30
00:02:25,400 --> 00:02:26,960
to be that unique ID.

31
00:02:27,440 --> 00:02:32,610
So we don't need to worry about the I.D. And then of course we need to set up a type.

32
00:02:32,990 --> 00:02:36,580
So what is going to be the type for our document?

33
00:02:36,590 --> 00:02:38,570
What is going to be typed for the item?

34
00:02:38,900 --> 00:02:42,560
And if you click over here, as you can see, these are our options.

35
00:02:42,560 --> 00:02:46,880
We can set it up as an array, binary boolean and yada, yada, yada.

36
00:02:47,060 --> 00:02:52,400
And I'm probably not going to spend too much time on types since I eventually will set it up from our

37
00:02:52,400 --> 00:02:53,350
server anyway.

38
00:02:53,750 --> 00:02:59,530
And at that point the setup is going to be a bit different since we'll use a tool called Mongo's.

39
00:03:00,020 --> 00:03:01,820
Now, in our case, what are we looking for?

40
00:03:02,090 --> 00:03:03,680
Well, we're just looking for the string.

41
00:03:04,110 --> 00:03:10,630
I'm just going to go here with name and then I'll set it equal first and product.

42
00:03:10,970 --> 00:03:18,110
So here, of course, I can insert and now not only I have the product collection, but I also have

43
00:03:18,110 --> 00:03:20,810
my first item, my first document.

44
00:03:21,440 --> 00:03:26,330
And here comes the biggest Gogia and Monaldi B documents have a dynamic schema.

45
00:03:26,750 --> 00:03:32,120
And what that means in plain English is the simple fact that documents in the same collection don't

46
00:03:32,120 --> 00:03:35,250
need to have the same set of fields or the structure.

47
00:03:35,840 --> 00:03:43,580
So if I were to go to insert document and instead of string, I'm going to go with array and I'm going

48
00:03:43,580 --> 00:03:49,390
to call this colors and then I'll set my first one to be read them second one blue.

49
00:03:49,760 --> 00:03:59,560
And if I'll save it as far as Mongo DB is concerned, they're still the same items in this product collection.

50
00:03:59,900 --> 00:04:02,020
So nothing stops you from doing that.

51
00:04:02,300 --> 00:04:08,660
Now, just because you can does not mean you should and therefore will use additional library by the

52
00:04:08,660 --> 00:04:12,170
name of a Mangoush, which will set up that structure for us.

53
00:04:12,440 --> 00:04:19,880
But as far as straight up Mongo DB, yes, both of these documents are still part of this product collection,

54
00:04:20,329 --> 00:04:23,960
even though their structure might be totally different.

