Warning: this post is old and might not reflect the current state of the art

Minimongo is your best friend when developing in Meteor. Ok, if you feel you have lots of best friends when using Meteor, I feel the same. Everything in Meteor is provided to ease your life.

Minimongo, in particular, is a frontend implementation of MongoDB. You might say.. what? Why do I need another database?

MongoDB: The Meteor Database

As of writing, Meteor has just one officially supported database: MongoDB.

You may wonder why. First, let me clarify: you can actually use any database you want, but to enjoy at 100% the marvels of Meteor you need to use Mongo. There are currently community projects that are working towards adding support for many other databases.

MongoDB in two words

MongoDB is a document-based database. It features high performance, high availability, easy scalability. It stores its documents in database collections. A document is a set of key-value pairs (JSON), and it has a dynamic schema. This means that each document does not need to have the same set of fields, but you have a great freedom in managing data.

Meteor and MongoDB

As said, a MongoDB document is just a JSON object. Meteor Collections are directly related to MongoDB collections, and the Meteor internals make sure that when data changes in a MongoDB Collection tracked by Meteor, the Meteor Collection is updated too.

Minimongo

In short, in Meteor you typically create a collection, and that collection is available on both client and server code. When you do some database query or database processing, you don’t “think” whether you should do that operation on the client-side database, or the server-side database: to a certain extent, they’re mostly the same thing. And they talk to each other transparently.

This means that when the server-side database (MongoDB) is updated by someone else or something happens in the app you’re using, or even you add something in a second browser window.. everything that’s stored in the database that interests your current session is pushed by the server MongoDB to the Minimongo running inside your browser.

The same happens for the opposite: you push a post to the Posts collection? Minimongo is updated immediately, while Meteor pushes the update to the MongoDB database server side.

This has the nice effect of making your changes, your pages and interactions feel immediate to the user.

Minimongo is a MongoDB client-side clone

Minimongo tries to perfectly emulate a subset of MongoDB. You can insert data, remove data, search, sort, update.. with the same exact MongoDB APIs.

This means you can also easily port some parts of your code from the server to the client-side very easily when it makes sense.

Client-side storage facility

With Minimongo you have a fantastic client-side storage that you can query using the MongoDB Query functionalities.

You can of course create instances of a Minimongo collection just client-side, when you don’t have the need to sync a collection to the server.

Not only, you can observe for database changes, and your interface can react to those changes easily.

Want to hire me?

I'm currently considering remote job/contract opportunities as a Frontend Developer.

Read more about me and if you're interested, get in touch.