1 00:00:02,290 --> 00:00:03,950 That's it for this module, 2 00:00:03,970 --> 00:00:07,230 we learned quite a bit about inserting documents. 3 00:00:07,300 --> 00:00:12,670 There basically is insert one and insert many, with these two methods, you can insert either one document 4 00:00:12,850 --> 00:00:15,530 at a time or multiple documents together. 5 00:00:15,820 --> 00:00:20,440 There also is the insert method like that but it's not recommended to use that anymore, 6 00:00:20,500 --> 00:00:24,200 insert one and insert many are clearer about what they do 7 00:00:24,430 --> 00:00:30,370 and additionally, the insert method gives you no feedback regarding the document IDs that were created 8 00:00:30,820 --> 00:00:34,300 and that can be a useful piece of information in many applications, 9 00:00:34,300 --> 00:00:38,310 so insert one and insert many are the methods to use. 10 00:00:38,360 --> 00:00:43,910 We also learned about ordered inserts, by default when using insert many, inserts are ordered, 11 00:00:43,910 --> 00:00:49,820 that means that if something goes wrong, if you have some error, let's say a duplicate ID, all the documents 12 00:00:49,970 --> 00:00:55,170 that would come after the document that caused an error will not be written to the database, 13 00:00:55,190 --> 00:00:57,620 the insert is basically stopped. 14 00:00:57,620 --> 00:01:03,440 You can change that by switching to an unordered insert with that ordered option 15 00:01:03,440 --> 00:01:09,900 you could specify on insert many, then your inserting process will continue even if you had an error. 16 00:01:10,070 --> 00:01:12,480 In both cases and that's important, 17 00:01:12,500 --> 00:01:14,800 successful inserts will never be rolled back, 18 00:01:14,810 --> 00:01:20,660 so even with an ordered insert, if you have an error, all documents that were added before that error 19 00:01:20,750 --> 00:01:22,350 will stay in the database. 20 00:01:22,490 --> 00:01:28,310 If you need a bulk operation that is rolled back in case of an error, you should later check out the 21 00:01:28,400 --> 00:01:33,430 transactions module towards the end of this course where I will dive into how that would work. 22 00:01:33,920 --> 00:01:39,470 Now we also had a look at the write concern and there you can control the level of guarantee you have that 23 00:01:39,500 --> 00:01:46,820 your write will succeed because you have that storage engine handling your write operation, 24 00:01:46,820 --> 00:01:52,450 keeping a journal which is like a To-Do list of tasks it needs to do and you can either wait for that 25 00:01:52,460 --> 00:01:55,870 journal being updated or you don't wait for this 26 00:01:56,090 --> 00:02:01,070 and depending on that, your write will be a bit slower but you have a higher guarantee that it really 27 00:02:01,070 --> 00:02:05,270 will happen eventually. Choose the value of that option, 28 00:02:05,270 --> 00:02:10,670 so whether you want to wait for journaling or maybe you don't even want to wait for the server to respond 29 00:02:10,670 --> 00:02:14,900 to your write request, choose that on your application requirements. 30 00:02:16,180 --> 00:02:21,950 And the last but not least, we also had a look at mongo import, that should have been pretty self-explanatory 31 00:02:22,030 --> 00:02:26,790 and now you should have a solid toolset for getting data into the database. 32 00:02:26,800 --> 00:02:32,980 Time to move on and learn how we can also read the data there and learn about the many options we have 33 00:02:32,980 --> 00:02:36,390 for filtering and getting exactly the data we need.