Mongo Explorer: Explore your MongoDB
In the past few months, I was looking for an excuse to write a native Mac Cocoa application. We use MongoDB at Bloom Digital to handle our analytics needs. I had tried mongohub, but my itch wasn’t scratched: I wanted something that displayed my data in tables, not as some kind of outline. Thus was born Mongo Explorer.
If you tell me “Why didn’t you fork mongohub and add your code”, I’ll tell you I was intimidated by a larger Cocoa application. I wanted something simple from which I could learn everything I wanted: from the grounds up. Of course, once I’m “done” (for some measure of done-ness), the code base will be much larger.
One useful piece of code that might be useful for others is a Mongo Driver for Objective-C. Underlying Mongo Explorer is an abstraction for Mongo connections that’s similar to the Ruby driver. It’s not yet a framework, since I don’t yet know how to do that, but hey, this is a learning exercise for me. One nice thing about this abstraction is that it’s built directly atop the official Mongo C driver: thus it inherits it’s abilities, but some of it’s quirks as well.
What can you expect from Mongo Explorer today? You can open a connection to any local MongoDB instance (manually open an SSH tunnel if you want a remote instance), browse the server’s databases and collections, and list your collection’s documents. For each document, you’ll get what I call the flat view. The flat view is a dot-separated list of keys, followed by the value. It’s useful to view nested objects:
1 obj = {"rp" => {"a" => 1, "b" => {"c" => "d"}}} 2 # Flat view 3 # rp.a => 1 4 # rp.b.c => d
The flat view was my biggest impetus to write Mongo Explorer.
What’s broken? First, this needs some kind of icon. Also, don’t expect to browse multi-million document collections just yet. Cocoa wants to fully materialize the NSTableView rows, and I don’t know how to handle that yet. I do have an MEArray class that helps somewhat, but it’s not perfect yet. Learning exercise, remember? I’ve successfully viewed collections with slightly less than 20,000 document with no issues.
If you’re interested in following, you can play around on GitHub, or even download the first official release: Mongo Explorer, v1.0.1
UPDATE: Pushed 1.0.1, as 1.0.0 didn’t include it’s frameworks, and was 10.6 only.
![]()
