That's it for this module,
we learned quite a bit about inserting documents.
There basically is insert one and insert many, with these two methods, you can insert either one document
at a time or multiple documents together.
There also is the insert method like that but it's not recommended to use that anymore,
insert one and insert many are clearer about what they do
and additionally, the insert method gives you no feedback regarding the document IDs that were created
and that can be a useful piece of information in many applications,
so insert one and insert many are the methods to use.
We also learned about ordered inserts, by default when using insert many, inserts are ordered,
that means that if something goes wrong, if you have some error, let's say a duplicate ID, all the documents
that would come after the document that caused an error will not be written to the database,
the insert is basically stopped.
You can change that by switching to an unordered insert with that ordered option
you could specify on insert many, then your inserting process will continue even if you had an error.
In both cases and that's important,
successful inserts will never be rolled back,
so even with an ordered insert, if you have an error, all documents that were added before that error
will stay in the database.
If you need a bulk operation that is rolled back in case of an error, you should later check out the
transactions module towards the end of this course where I will dive into how that would work.
Now we also had a look at the write concern and there you can control the level of guarantee you have that
your write will succeed because you have that storage engine handling your write operation,
keeping a journal which is like a To-Do list of tasks it needs to do and you can either wait for that
journal being updated or you don't wait for this
and depending on that, your write will be a bit slower but you have a higher guarantee that it really
will happen eventually. Choose the value of that option,
so whether you want to wait for journaling or maybe you don't even want to wait for the server to respond
to your write request, choose that on your application requirements.
And the last but not least, we also had a look at mongo import, that should have been pretty self-explanatory
and now you should have a solid toolset for getting data into the database.
Time to move on and learn how we can also read the data there and learn about the many options we have
for filtering and getting exactly the data we need.