Studio 3T lets you view a collection in Tree View, Table View, and JSON View. In this exercise, you will review the welsh_pubs collection in all three views. You will also update some preferences to make it easier to view documents in Tree View.
To review the collection
1. On the welsh_pubs collection tab, select Table View from the drop-down list in the top right corner of the Result tab.
Table View displays the document data in a grid that contains one column for each top-level field in the documents:
- Fields defined with the Object data type show the total number of fields in each embedded document. In this case, three fields contain embedded documents: address, location, and contact. Less than a third of the documents include the contact field.
- Fields defined with the Array data type show the total number of elements in each array. In this case, no documents include arrays.
- All other fields display the scalar values. For example, fields might show String values or Int32 values.The following table shows the icons associated with some of the more common data types.
Type | Icon | Definition |
Array | Contains a group of elements, which typically are all of the same data type such as an integer or string. An array data type makes it possible to store multiple values in one field. (source) | |
Date | Contains date values, time values, or date and time values. (source) | |
Int32 | Represents signed integers with values that range from negative 2,147,483,648 (which is represented by the Int32.MinValue constant) through positive 2,147,483,647 (which is represented by the Int32.MaxValue constant. (source) | |
Int64 | Represents signed integers with values that range from negative 9,223,372,036,854,775,808 (which is represented by the Int64.MinValue constant) through positive 9,223,372,036,854,775,807 (which is represented by the Int64.MaxValue constant. (source) | |
Object | Used for embedding documents. Embedded documents are documents embedded in another document in the form of a field-value pair. (source) | |
ObjectId | Small, likely unique, fast to generate, and ordered, ObjectId values consist of 12 bytes, where the first four bytes are a timestamp that reflect the ObjectId’s creation. (source) | |
String | The most commonly used data type. Used to to represent text rather than numbers. It is comprised of a set of characters that can also contain spaces and numbers. (source) |
2. Double-click any address value (not the field header) to go one level deeper into the embedded documents for that field.
The grid now displays the individual values of the embedded documents, along with the _id
values, as shown in the following figure.
3. To return to the top-level fields in the grid, click the welsh_pubs link in the breadcrumb navigator just above the grid.
4. On the Result tab, select Tree View from the drop-down list near the tab’s upper right corner.
Tree View displays the document data in a grid that contains three columns—Key, Value, and Type—with each document in its own row.
The Type column refers to the data type, which in this case, is Document.
5. You can use the Studio 3T preferences to control how various elements are displayed.
To open the preferences:
- In Windows, select Preferences from the Edit menu.
- In macOS, select Preferences from the Studio 3T menu.
6. Review the options available in the Preferences dialog box.
These settings can help you personalize the interface and make you more productive. For this exercise, select the Auto-expand first document in tree view check box on the General tab, and then click OK.
7. On the Result tab toolbar, click the Refresh button.
The first document should now be expanded to the first level.
Notice that the Type column displays the data type of each field. The address and location fields are configured with the Object data type because they contain embedded documents.
8. Click the arrow to the left of the address field.
This expands the field to display the individual fields in the embedded document.
9. Expand the arrow to the left of the location field to view the individual geospatial fields.
10. Select JSON View from the drop-down list in the upper right corner.
Studio 3T now displays the documents in the JSON format.
In JSON View, you can see the name/value pairs for each field and embedded document. This view is more consistent with how data is added and stored in a MongoDB database.
11. Return to Table View and leave the collection open for the next exercise.