The next thing to do is to make sure the service is running OK and we can do that using the command line shell. So create a few collections in the (default) test database and make sure everything is OK. You’ll see a few files created in your c:\mongodb\data\db directory. You’ll also see some logging in the c:\mongodb\logs\ directory.

Creating a database:

To create a database you just need to switch to that database. For example to create a ‘logging’ database just switch to the database and create a new collection by simply saving one, for example:

>use logging;
>db.foo.save({ name : "dillon"});

Capped collections:

What I want to use Mongo for – just for now – is logging. I have a task that runs every few minutes and sends a lot of emails. I want to be able to log each and every email along with who we sent it to and the type of email. This is where Mongo’s capped collections come in. This type of collection will have a max size and older information will be discarded – like a self-managing log.

I want to create a 100MB capped collection, so to do that I need to allocate 104857600 bytes. But I can also cap the number of objects in the collection. So I’ll say I only want a maximum of 10,000 objects in my collection. So from the console I can run: