1 00:00:02,210 --> 00:00:04,890 So here is some data I prepared, 2 00:00:05,150 --> 00:00:08,750 now you'll find that data attached to this video by the way. 3 00:00:09,170 --> 00:00:09,560 It is a 4 00:00:09,560 --> 00:00:14,180 json file and this json file actually holds an array 5 00:00:14,300 --> 00:00:17,870 hence the square brackets here of two json documents, 6 00:00:17,870 --> 00:00:23,990 so this is one single json document and this is another json document and we entered one such document 7 00:00:24,080 --> 00:00:26,930 with insertOne, we don't insert both. 8 00:00:27,110 --> 00:00:33,920 We insert one such document with insertOne and this would be one piece of information about a flight. 9 00:00:33,920 --> 00:00:39,800 Now here, I got these key value pairs and that is how a json document is basically made up of, you 10 00:00:39,800 --> 00:00:46,640 have names which you enclose between double quotation marks and these double quotation marks are important 11 00:00:46,730 --> 00:00:55,100 and have to be used and then you got the values for these names or keys and here, the values can be different 12 00:00:55,100 --> 00:00:56,090 kinds of data. 13 00:00:56,090 --> 00:00:57,670 Here we got a string, 14 00:00:57,720 --> 00:01:02,180 so some text basically which is surrounded by quotation marks. 15 00:01:02,180 --> 00:01:03,500 Here we got a number though 16 00:01:03,620 --> 00:01:05,300 and there we don't have quotation marks, 17 00:01:05,330 --> 00:01:09,510 so the values don't have to use quotation marks, only the names here. 18 00:01:09,710 --> 00:01:14,670 The values can be strings and then they have quotation marks but they can also be numbers or like this, 19 00:01:14,780 --> 00:01:16,180 a so-called boolean, 20 00:01:16,220 --> 00:01:17,600 so true or false, 21 00:01:17,660 --> 00:01:19,820 this also has no quotation marks. 22 00:01:19,820 --> 00:01:23,660 There also are some other types of data which we'll see throughout the course, 23 00:01:23,660 --> 00:01:27,210 these are three very important types of data which you will use a lot though, 24 00:01:27,320 --> 00:01:29,640 so this is one json document we could enter. 25 00:01:29,870 --> 00:01:31,980 So let's grab this document, 26 00:01:32,060 --> 00:01:37,790 again you'll find this file attached and just that one document including the curly braces but not the entire 27 00:01:37,880 --> 00:01:38,940 array, 28 00:01:38,960 --> 00:01:49,920 grab that document and then back in your terminal here, you can copy that document between those braces, 29 00:01:49,970 --> 00:01:53,270 important before you copy it in, delete the closing parentheses, 30 00:01:53,360 --> 00:01:55,040 then add it and then close it. 31 00:01:55,040 --> 00:02:02,230 Now if you hit enter, you should see this message here which basically tells you that this was accepted and 32 00:02:02,240 --> 00:02:08,660 was inserted successfully and that it also assigned an automatically created ID. 33 00:02:08,660 --> 00:02:11,110 Now that's a feature provided by mongodb, 34 00:02:11,180 --> 00:02:17,750 every document you enter gets a unique ID and actually, you need to have a unique ID on every element 35 00:02:17,780 --> 00:02:24,470 but as you saw here, you don't need to specify it on your own, mongodb gives you one, it's of type objectId 36 00:02:24,530 --> 00:02:31,100 so this another type supported by mongodb which we can use and we can see it if we now simply have 37 00:02:31,100 --> 00:02:32,890 a look at our flight data. 38 00:02:32,930 --> 00:02:34,300 Let me clear the console 39 00:02:34,460 --> 00:02:41,060 and again if I now access flight data, so this collection, now instead of inserting, we can use find like 40 00:02:41,060 --> 00:02:41,560 this 41 00:02:41,690 --> 00:02:46,040 and if we use it like this, it will simply return all the documents in this collection. 42 00:02:46,040 --> 00:02:50,220 You can also add another dot and then pretty as a function 43 00:02:50,300 --> 00:02:55,470 and this will just make sure that the output we get back is formatted in a pretty way. 44 00:02:55,550 --> 00:02:59,790 That's the only thing it does, find without pretty will also work, 45 00:03:00,030 --> 00:03:05,220 it'll look like this but and you can press arrow up to repeat your last command, 46 00:03:05,370 --> 00:03:10,470 if you add pretty, it looks like this which is easier to read and there we see all the data we entered 47 00:03:10,500 --> 00:03:15,490 plus this extra _id which was added automatically by mongodb 48 00:03:15,630 --> 00:03:21,840 and this objectid object is simply a special type of data provided by mongodb which is a unique 49 00:03:22,380 --> 00:03:29,630 ID that also allows you to sort your documents because it will also have some time stamp data in there 50 00:03:29,620 --> 00:03:35,280 you could say. So this id also can be used for sorting because it's guaranteed that if you would add 51 00:03:35,430 --> 00:03:42,180 another document right now, this would be treated as a more recent document than this document we see 52 00:03:42,180 --> 00:03:43,400 here due to that id. 53 00:03:43,410 --> 00:03:45,310 But that's some behind the scenes stuff, 54 00:03:45,360 --> 00:03:48,190 the important part is we got our data in there, 55 00:03:48,240 --> 00:03:53,000 you still see we have the same data types we added like the number still is a number, 56 00:03:53,010 --> 00:03:54,930 there are no quotation marks around it 57 00:03:55,110 --> 00:04:02,190 and this is now valid json data inserted into our database or into our collection in that database 58 00:04:02,190 --> 00:04:03,000 to be precise.