[MUSIC]
We're now going to take a little aside and find out how we can actually look
at the underlying database, which meteor is working with in our applications.
So far, it's kinda been hidden from view.
It's just this mysterious thing that we can dump things into and
pull things out of, but there's actually quite a lot going on in there,
which it's really interesting to have a poke around and see what's happening.
So first of all, let's find out what underlies the user accounts and
the way we do it is with the mongo shell.
So if you're, let's just check if your app is running.
So if you run meteor, looks like it's already running.
So to access the mongo shell, we type meteor mongo and
that logs in to the local database server.
So the default database server in meteor is mongo and
when we first installed meteor, it actually installed the mongo server for
us as well as the meteor layers on top of that.
And indeed, the Node.js system.
So there's a whole bunch of components inside that meteor framework,
which is getting stored automatically.
We don't need to worry about, but we're sort of now gonna unveil one of those,
which is the database server.
And mongo is a standard database server, which is of the category kind of no SQL.
So we might call it, we recorded a NoSQL database.
There are other types of databases and some of them you can use with meteor.
For example, the SQL database is MySQL and PostgreSQL.
The difference between these and the mongo has to do with how you store your data.
So mongo is quite open-minded about how you kind of store your data,
you don't have to specify schema beforehand, like table structures.
You just chuck stuff in there and kind of get on with it and
that's really a nice way of working with data for certain applications.
So let's just see what's in there, anyway.
So we're logged into mongo and
what we can do is ask it, which collections it has?
Now collections may be familiar if you remember that in our JavaScript code,
we defined a collection called documents.
And when we created it, we actually specified a string containing the word
documents and that's what the mongo collection is actually going to be called.
And indeed, there we have one collection called Mongo.
So we can do db, which refers to the database and
the name of the collection, which is documents and
findOne, which will pull out a document.
There it is.
And actually, there is only one document in there.
So if I do find() count(), you see it gives me a count of one.
So that's because everybody works on the same document,
because we've only got a single document in our collaborative document editor.
How about users?
But you see there's also another collection in there called users.
The reason I'm getting confused between the word collection and table is,
in more traditional databases like MySQL and PostgreSQL, we talk about tables.
In Mongo, we talk about collections.
So there's a user's collection there,
so db.users.findOne.
There's a user account and
let's just see how many there are.
There's one and if I was to go back to my application and
actually create a new user account, you will see and
that test call it test2@test.com, testtest.
There's now two accounts sitting there in the thing and
we can look at both of them by calling find and telling it to prettify it.
If we don't prettify it, it just looks like this.
Just a kind of flat dataset, but pretty kind of puts some formatting in there, so
it's a bit easier to read.
So what does a user account look like?
Well, here is one here.