So we're almost done,
no worries,
it's soon time to get our hands dirty.
Now let me quickly give you an overview over how exactly you will work with mongodb and what
mongodb
exactly does behind the scenes. So we can generally differentiate between the application,
so let's say your node application you are creating and the data layer.
Now in your application, you will have some frontend that can be a single page application, that can
be a mobile app, that can be the views your level or your node app renders.
You'll then have a backend, your server where you have your server side logic and then you have your
data layer,
so you have the database, the data storage, the files on a file system which hold your data in the end. You
have the mongodb server and you have on the backend server where you will write your code,
you have these drivers for the different languages.
Now the drivers will interact with the mongodb server, the mongodb server is what we started with
the mongod command
by the way. Now the mongodb server will actually not directly write the data into files but talk to
a so-called storage engine which you could replace with your favorite storage engine
but the default one called Wired Tiger is actually an awesome storage engine which allows you to efficiently
work with your data, store it efficiently and so on.
So the mongodb basically gets the query from your driver or from your shell and then just
knows I want to insert something and basically forwards that information after doing some other things to
the storage engine and the storage engine then stores it in files in the end.
And instead of the drivers, you can of course also use the mongo shell, there you can also write all the
queries and as you will also see in this course, you would also use the mongo shell as a general playground
and also for administrating your server because that is not something your app will do if you have to
configure something, you would do this as an administrator from your company network through that shell which
is your direct access to the mongodb server.
Now if we have a closer look at that data layer with the server, the storage engine and the file system, then
we actually have to differentiate between writing and reading from files which is a bit slower and writing
and reading from memory which is faster.
The storage engine actually does both,
it loads a chunk of data into memory and manages that such that the data you often use is in memory of
possible,
it also writes data in memory at first so that this is really fast
but then of course it also goes ahead and stores data in the database files and I will dive a little
deeper into that later in the course
but in general, you need to be aware that you always talk to the mongodb server and behind that server,
the server talks to the storage engine which manages your data and stores it in files
in the end but also in memory in between so that you can work with the data in a very fast way.
So this is how the mongodb server works behind the scenes you could say.