Discovered a new tool for working with MongoDB: MongoChef from 3T Software Labs

I thought this was worth sharing. A former colleague of mine from Red Gate put me in touch with an awesome company called 3T Software Labs, who have a suite of tools for working with MongoDB, including a great shell for MongoDB called MongoChef. I was fortunate enough to be able to spend some time this afternoon running through a usability test on MongoChef with one of 3T’s co-founders, Thomas Zahn.

Up until now I’ve used both RoboMongo and MongoVUE for this kind of work, both of which have their strengths and weaknesses, and inevitably I’ve ended up using them both for different purposes.

MongoChef seems to offer the best of both whilst also being more capable and is being rapidly developed on a very short release cycle so the improvements seem to be coming thick and fast, so I suspect it’ll replace them both from now on.

Anyway, I really just wanted to run through some of the functionality very quickly…

First off, download and install MongoChef. If you want to use the integrated shell, make sure you’ve also got the MongoDB binaries installed.

Connecting to a MongoDB instance is dead simple. Just click the big green Connect button on the welcome screen, or use the corresponding toolbar button:

MongoChef welcome screen Connect button

This opens up the Connection Manager:

MongoChef Connection Manager dialog

Now click New Connection, and give your connection a name. The really nice thing is that it’s easy to populate this dialog from a URI, for example, one that you use in your web.config, using the From URL button:

Creating a new MongoDB connection in MongoChef

Just paste in your URI, click OK, and you’re good to go:

Populating the New Connection dialog from a URI

Likewise, if you need a URI as a connection string, you can grab that using the To URI button:

Exporting a URI from connection settings in MongoChef's New Connection dialog

Just double-click on any connection in the Connection Manager to connect to that instance.

Active connections are shown in the treeview on the left of the main window. You can drill in to view databases and connections:

Treeview showing active MongoDB connections

You can double-click on a collection to open it. Pagination is customisable and you can drill into documents:

MongoChef's collection view

There are also three different views for documents: Tree View, Table View, and JSON View.

Different view styles for MongoChef's collection view

My favourites are definitely Tree View and JSON View. Table View works particularly well for very flat documents.

Tree View works best with the Query Builder, which is a handy way to quickly throw together queries without having to scratch your head over the syntax. It’s particularly helpful if, like me, you’re from a SQL background, so tend to know what data you want back (and how you’d like it structured), but struggle a little to express that in JavaScript rather than SQL.

To use the Query Builder just hit the corresponding button in the top-right of the collection view:

Click the button to open the Query Builder

To build your query, just:

  • drag the fields you want to query against into the Query section, and set the query criteria for each field
  • drag the fields you’d like to sort by into the Sort section,
  • the fields you’d like returned into the Projection* section.

*A projection defines the subset or shape of data you’d like to receive back from MongoDB. It’s analagous to the column list after SELECT in a SQL query.

Then, to run your query, just click the Run button. Here’s an example:

Using the Query Builder

The one thing missing here is a script view that would display the JavaScript for the query, which would be a handy teaching tool, but Thomas assures me this is coming – they’re working on it right now in fact.

Editing documents is just as easy as querying. Just double-click on the value you want to edit and type in something else. This even works with projections:

Editing a document in the collection view

If you prefer to get a bit lower level and want to bash out queries directly in JavaScript you can access the integrated shell via the Shell toolbar button:

Use the Shell toolbar button to open the integrated shell

Enter your query in the pane at the bottom of Shell, which includes intellisense/autocomplete to help you, which is absolutely invaluable. If it takes to long to appear just use the standard CTRL+SPACE shortcut to force it:

Editing a query in MongoChef's integrated shell with intellisense/autocomplete

You can hit ENTER to execute your query. Results appear in the pane at the top of the Shell.

Query results in the integrated shell

If this isn’t the behaviour you want just uncheck Enter Executes.

If you’ve ever installed MongoDB from scratch you’ll know that setting up users can be a royal pain in the backside. Fortunately MongoChef provides help with user management too.

Just select the database you want and click Users on the toolbar:

Accessing the user management view in MongoChef

You can drill into each user to see which roles they have. Click Add to add a new user:

MongoChef's user management view

Assign a username and password to your new user. If you want them to be able to do anything, you’ll also need to assign one or more roles to them. Click Grant Roles to do this:

Adding a user in MongoChef

To assign a single role, just double-click on it. To assign multiple roles, use CTRL+Click to multi-select, then click Grant:

Assigning roles to a user

Back in the Add User dialog box just click the Add User button, and you’re done.

This is by no means a comprehensive look at all the features available in MongoChef, but hopefully it’s given you a flavour of what the tool can do. I’d strongly recommend you try it yourself though, so here’s that download link again.

MongoChef is available for Windows, OSX, and Linux, and is compatible with all recent 2.x versions of MongoDB, along with the latest 3.0 release. It’s free for personal, non-commercial use, and a snip at US$69 + VAT for a commercial license.


2 thoughts on “Discovered a new tool for working with MongoDB: MongoChef from 3T Software Labs

  1. Pingback: Why we invested in 3T’s MongoChef - The Red Gate blog

  2. Pingback: MongoDB | geek in pink

Leave a Reply

Your email address will not be published. Required fields are marked *