One of the strengths and challenges of MongoDB is the fact that in storing data in JSON-like field value documents, the opportunity to introduce very sparse and deeply nested data into a collection is a real possibility. So the strength is the ‘schema-less-ness’ of the data, but the problem for end users is unwinding that data to obtain useful data.
That’s where Toad begins to provide value. Keep in mind, if you are a MongoDB Purist, you can use the MongoDB CL interface (there’s even one built right into Toad), but for quick and easy analysis, Toad’s Outline View has some fantastic functionality.
Let’s explore this feature with a use case…say you want to figure out how many Windows users are in your dataset, the default option is to use the MongoDB CL (it’s easy enough), but it assumes you know a lot about the data and columns available in the collection before you start writing queries…which isn’t always the case.
So, that said, I want to do a select * from mycollection where OS = ‘windows’ type command, but when there’s dozens of fields to comb through, it’s easier just to start by searching for a string with the term OS within the field names in the Outline view so an unusable mess like this…
…becomes something more digestible like the screenshot below, which has filtered out all of the non-essential fields and focuses on the data I’m interested in. So in this case, I type OS in the filter dialog, and we’re auto-magically narrowed down from dozens of fields to 3:
So with a refined view into the JSON doc, it’s easy to experiment with the data, and see which users are on the Windows OS platform. To wit, now in the Outline View, click in the Filter field for the ‘osType’ Field, and type ‘windows’ (If it helps, this is a regex-like text filter, so use wildcards that you are familiar to get more complicated) then enter…
Two things happen, 1) the Grid/JSON data fields are updated to show only documents meeting our filter criteria and 2) the status bar is updated to reflect the impact of filtering by the term ‘windows’ (down from showing all 819K documents to the 562K matching documents). Easy Peasy, no need to write any script, perfect for the casual SQL/NoSQL user!
Now, with the data filtered, I can share that dataset or add it to my favorite editor with a quick copy paste. In this example I just click on the JSON tab, right click | Select All | Right Click | Copy and then paste to capture the filtered dataset!