1 00:00:02,160 --> 00:00:04,120 That's it for this module, 2 00:00:04,320 --> 00:00:10,080 we had a detailed look at databases collections and documents and what all these things are. That a database 3 00:00:10,080 --> 00:00:14,040 holds multiple collections and each collection can then hold multiple documents, 4 00:00:14,040 --> 00:00:20,110 this is how mongodb structures its data. Databases and collections are created lazily, 5 00:00:20,130 --> 00:00:26,920 that means only when a document is inserted, only when you need a specific database or collection. A 6 00:00:26,910 --> 00:00:29,550 document can't directly be inserted into a database, 7 00:00:29,550 --> 00:00:31,190 it's always part of a collection, 8 00:00:31,200 --> 00:00:37,070 so keep that layered architecture in mind. Documents have a certain structure, 9 00:00:37,350 --> 00:00:41,700 each document needs a unique ID which has to be called _id, 10 00:00:41,730 --> 00:00:48,000 you can set this on your own or take the one mongodb creates for you and you can have embedded documents 11 00:00:48,090 --> 00:00:54,390 as well as arrays as well as texts, numbers, all the other data types you already saw and we'll dive in later 12 00:00:54,450 --> 00:00:56,220 in this course. 13 00:00:56,400 --> 00:01:02,850 An important part or aspect of working with a database is that you can perform crud operations, 14 00:01:02,850 --> 00:01:06,350 that stands for create, read, update and delete. 15 00:01:06,380 --> 00:01:12,030 Mongodb offers multiple crud operations for a single document and bulk actions, you can insert one element 16 00:01:12,060 --> 00:01:18,240 or one document or many documents and you can find many documents or find one document. 17 00:01:18,300 --> 00:01:24,920 Some methods require arguments, insertOne for example needs to know what you want to insert, other methods 18 00:01:24,930 --> 00:01:31,990 like find can use arguments as you will see and as you already saw in this module but don't need one. 19 00:01:32,710 --> 00:01:33,680 Find by the way also 20 00:01:33,710 --> 00:01:39,290 returns a cursor, not a list of documents, that cursor is useful for manually going through the documents 21 00:01:39,470 --> 00:01:44,300 because otherwise all the documents which could be thousands or millions would have to be transferred 22 00:01:44,360 --> 00:01:50,130 over the wire in one go which would not be that great for your bandwidth and your connection. 23 00:01:50,690 --> 00:01:57,350 You can use filters on find and also on update and delete to narrow down which documents you want to 24 00:01:57,350 --> 00:01:57,830 find 25 00:01:57,860 --> 00:02:01,050 or you want to update or you want to delete. 26 00:02:01,090 --> 00:02:02,070 Last but not least, 27 00:02:02,200 --> 00:02:07,660 talking about retrieving data, you should be aware that you can use filters and operators, filters and 28 00:02:07,660 --> 00:02:13,430 operators basically allow you to narrow down the set of data you found like the greater than operator 29 00:02:13,570 --> 00:02:18,970 and you can identify all these special operators provided by mongodb by the fact that they start 30 00:02:18,970 --> 00:02:20,380 with a dollar sign 31 00:02:20,500 --> 00:02:26,200 and this allows you to simply limit the amount of data you are fetching. And you can use projection to 32 00:02:26,200 --> 00:02:32,650 then take the data you fetched and tell mongodb which fields you actually want to get and which you don't 33 00:02:32,650 --> 00:02:33,360 want to get, 34 00:02:33,400 --> 00:02:38,800 so filters allow you to restrict the amount of documents, projections then allow you to restrict the 35 00:02:38,800 --> 00:02:40,450 amount of fields per document 36 00:02:40,450 --> 00:02:43,470 so to say. These are the basics, 37 00:02:43,480 --> 00:02:44,560 let's now move on.