That's it for this module,
we had a detailed look at databases collections and documents and what all these things are. That a database
holds multiple collections and each collection can then hold multiple documents,
this is how mongodb structures its data. Databases and collections are created lazily,
that means only when a document is inserted, only when you need a specific database or collection. A
document can't directly be inserted into a database,
it's always part of a collection,
so keep that layered architecture in mind. Documents have a certain structure,
each document needs a unique ID which has to be called _id,
you can set this on your own or take the one mongodb creates for you and you can have embedded documents
as well as arrays as well as texts, numbers, all the other data types you already saw and we'll dive in later
in this course.
An important part or aspect of working with a database is that you can perform crud operations,
that stands for create, read, update and delete.
Mongodb offers multiple crud operations for a single document and bulk actions, you can insert one element
or one document or many documents and you can find many documents or find one document.
Some methods require arguments, insertOne for example needs to know what you want to insert, other methods
like find can use arguments as you will see and as you already saw in this module but don't need one.
Find by the way also
returns a cursor, not a list of documents, that cursor is useful for manually going through the documents
because otherwise all the documents which could be thousands or millions would have to be transferred
over the wire in one go which would not be that great for your bandwidth and your connection.
You can use filters on find and also on update and delete to narrow down which documents you want to
find
or you want to update or you want to delete.
Last but not least,
talking about retrieving data, you should be aware that you can use filters and operators, filters and
operators basically allow you to narrow down the set of data you found like the greater than operator
and you can identify all these special operators provided by mongodb by the fact that they start
with a dollar sign
and this allows you to simply limit the amount of data you are fetching. And you can use projection to
then take the data you fetched and tell mongodb which fields you actually want to get and which you don't
want to get,
so filters allow you to restrict the amount of documents, projections then allow you to restrict the
amount of fields per document
so to say. These are the basics,
let's now move on.