Views
On this page
Views are read-only results of an aggregation run against a collection. Views provide easy access to the results of an aggregation without requiring the reader of the view to execute the pipeline. Views can also help keep your data secure by only giving users access to a predefined result set, as opposed to having access to the underlying collection.
Collections Screen
The Collections screen lists the existing collections and views in the selected database. Each list item includes the name and other general information for the collection or view.
To access the Collections screen for a database, from the Databases screen either:
Click a Database Name in the main Databases view, or
Click a database in the left navigation.
Compass displays views in the Collections Screen with a special icon, and indicates the collection from which the view was created.
View Information
The Collections screen displays the following information for each view in the selected database:
View name
Collection from which the view was created
Create a View
To create a view, you must use the Aggregation Pipeline Builder. The output of your pipeline's final stage becomes the content of the view.
To create a view from your pipeline results:
Create an aggregation pipeline in the pipeline builder. For detailed instructions on using the pipeline builder, see Create an Aggregation Pipeline.
Click the arrow next to the Save button at the top of the pipeline builder.
Click Create a View.
Enter a name for your view.
Click Create.
Compass creates a view from your pipeline results in the same database where the pipeline was created.
Open a View
To open a view, either:
Click the desired view from the Collections screen, or
Click the desired view in the left-hand navigation.
After you open a view, Compass shows you that view's Documents Tab. Compass provides the following information and functionality for the view:
Duplicate a View
You can duplicate a view to modify an existing view while retaining the original.
To duplicate a view:
Hover over the desired view in the left navigation.
Click the appearing Ellipses (...) button.
In the drop-down menu, click Duplicate View.
Enter a name for the new view.
Click Duplicate.
Modify the Source of a View
Note
Considerations
Views are read-only, and cannot inherently be modified. This procedure describes modifying the underlying source of a view.
When you modify a view, Compass cannot retain collation information associated with the view. Any collation information must be re-entered in the pipeline builder during modification.
To modify the source of a view:
Hover over the desired view in the left navigation.
Click the appearing Ellipses (...) button.
In the dropdown, click Modify view. This button opens the aggregation pipeline builder and populates the pipeline used to create the view.
Modify the pipeline as desired. For detailed instructions on using the pipeline builder, see Create an Aggregation Pipeline.
Click Update View at the top of the pipeline builder.
Drop a View
To drop a view from the database:
Hover over the desired view in the left navigation.
Click the appearing Ellipses (...) button.
In the dropdown, click Drop View.
In the modal, enter the name of the view.
Click Drop Collection.