Now we did insert some data.
So that's the C of the Crowd Operations.
Now, how can we get that data?
How can we read that data?
Well, that is thankfully also rather straight forward.
To read our data.
So to do something on the R of the Crowd Operations.
We can simply, again, type DB.
Then the name of our collection,
which was created automatically, as I told you,
as soon as we started inserting data.
And then to get all the documents in this collection,
you can just execute, find like this.
And this will then find you all the data in there.
And as you can see,
here we've got the two documents we inserted
with that automatically generated ID and the data we added.
Now, of course, you don't always wanna
find all the documents and therefore you can also filter.
You filter by passing a JavaScript object.
So to say, to find
which now does not define a document
you wanna insert of course, but instead,
which simply is used to group the different options
or conditions for finding.
And here you can simply reference
the different keys you have in your documents.
For example, you could point at name year.
And then after a colon,
you specify the value you wanna look for.
For example, if I look for a Munich Schnitzelhouse here
and I now hit enter, I only find one document, of course,
because I only have one document with this name.
And of course you can also not just look for equality,
but in stat, if you're working with numbers,
you can also look for a greater
or smaller than numbers and so on.
So there's a lot you can do here.
Now, when you find documents, you also don't have to include
all the key value pairs of the documents in the results set.
Instead, if you wanna let's say, find all your documents.
So I switched us back to find without any argument,
but then I'm only interested in the name of the restaurants,
but not in the address.
Then you can simply pass an empty object
as a value for the conditions parameter.
And then add a comma to pass an optional second parameter.
Which is another object where you now control
the so-called protection of the documents that are found.
For example, here you can type name one.
Which means that you want to include the Name Field.
If you hit enter, now we get back all the documents,
but for every document, we only see the name.
In the collection, we still have the extra data
like the address, but here in the result,
we only get back the name.
And by default all the ID.
If you don't want the ID, you can also add underscore ID.
Since that's the name of the ID Field
and type zero to exclude it.
And in general, by typing zero for a field it's excluded.
By typing one it's included.
And if you include at least one field,
all other fields, except for the ID
are automatically excluded.
So that's how you can control which fields
you wanna get for which documents.
So the first parameter value
allows you to define conditions,
to control which documents are fetched.
The second parameter value allows you to control
which fields are shown for the fetched documents.
And that's how you can query your data.
Now, sometimes you'll also wanna
get exactly one document and you know,
that you wanna get only one document.
For example, if I, again, filter for the documents
where the name is Munich Schnitzelhouse.
I know that there is only one document
in there that has this name.
It would even be clearer, if I would be looking
for the specific ID of this document.
Still, if you look closely, you see that the actual result
I get back here is an array.
It's a list of documents.
The reason for that is, that if you're using Find MongoDB,
doesn't know if there will only be one match.
We know that there is only one restaurant with that name,
but that's of course not guaranteed.
We could have multiple restaurants with that name.
And therefore, if you only wanna get one document,
the first matching document in case
you would have multiple matches.
Then instead of using Find, you can use Find one.
And then still pass, your filtering condition
as a first parameter value.
And you could still also set up projection here .
With Find One, I also get only that one document,
but now it's not inside of an array.
It's not a list.
Instead, it's the first matching document
that met this condition.
So find, and find one with the configurations I showed you.
Here are your reference if you wanna find and query data.
Now, of course there is way more you can do.
Different ways of structuring your conditions and so on.
And therefore, I do have a full MongoDB course,
if you wanna dive deeper.
Or you check out the official free MongoDB documentation.
This course will only get you started with MongoDB.
For a deep dive,
definitely visit that official documentation.
Or have a look at that full course I got.
But now with that recovered the C and the R
of the Crowd Operations.
Now let's see how we can update data.