Compass

MongoDB Compass is a GUI for MongoDB. It is also known as MongoDB GUI. MongoDB allows users to analyze the content of their stored data without any prior knowledge of MongoDB query syntax. When we explore exploring our data in the visual environment, we can use Compass GUI to optimize performance, manage indexes, and implement document-validation.

All the versions of MongoDB Compass are opensource (i.e., we can freely deploy and view the repositories of all MongoDB GUI versions). The source repositories of MongoDB compass can be found on the following link of GitHub

https://github.com/mongodb-js/compass/

Available Compass Edition

MongoDB GUI is available in the following four editions:

  • Compass Community: This edition is designed for developing with MongoDB and includes a subset of the features of Compass.
  • Compass: It is released as the full version of MongoDB Compass. It includes all the features and capabilities that MongoDB provides.
  • Compass Randomly: It is limited to read operation only with all update and delete capabilities removed.
  • Compass Isolated: The Isolated edition of MongoDB compass doesn't start any network requests except to the MongoDB server to which MongoDB GUI connects. It is designed to use in highly secure environments.

How to Download and Install MongoDB Compass

Step 1: To download MongoDB Compass, you can use your preferred web browser, and Open the https://www.mongodb.com/download-center/compass?jmp=docs page.

Step 2: You need to select the installer and version you prefer. GUI installer are available as a .exe or .msi package or a .zip archive.

Step 3: Finally, Click on the download button.

MongoDB Compass

Step 4: Click on the installer file after the download is complete.

Step 5: Follow the pop-ups to install MongoDB Compass GUI.

Step 6: Once it is installed, it launches and ask you to configure privacy settings and specify update preference.

MongoDB Compass

Update MongoDB Compass

There are two ways we can use the updated version of MongoDB Compass

1. We can download and install the latest released version of MongoDB GUI from the official website of MongoDB at any time. We need to check the S/W and H/W requirements for our OS and required version of MongoDB compass to ensure Compass GUI is compatible with our system.

2. We can update Compass by enabling the automatic updates from the Help -> Privacy Settings as shown below.

MongoDB Compass MongoDB Compass

Establishing connection with MongoDB Compass.

There are two methods to connect our deployment in MongoDB compass, either we can use the connection string provided on the MongoDB Atlas or we can fill our deployment information in specified fields.

By Pasting Connection String.

Step 1: When you log in to Compass, an initial dialogue will appear.

Step 2: To get the deployment connection string for an Atlas cluster, go to your Atlas cluster view.

MongoDB Compass

Step 3: Click Connect for the cluster you want to connect.

MongoDB Compass

Step 4: After that, click Connect with MongoDB Compass and copy the provided connection string.

MongoDB Compass

Step 5: Click on connect button, to connect and navigate to the Compass GUI Home Page.

MongoDB Compass

The Compass Home screen displays the details about the MongoDB instance from which Compass is connected, which includes the connection name, the deployment type, hostname, and port, version of MongoDB, performance statistics, and a list of the instance's databases.

Creating and Managing Database using Compass

When you are connected to the MongoDB Atlas or Mongo Shell, the following window will appear. Inside this window, you can see the Database tab. The Database window shows the lists of all the existing databases for your MongoDB deployment.

MongoDB Compass

On the above window, when you select a database from the given list to view its collections. You can view database collection when you click the desired Database in the left navigation pan.

Create a Database in Compass

Step 1: Click on the Create Database button from the database tab. It will take you to the Create Database pop-up dialogue.

MongoDB Compass

Step 2: In the appeared pop-up window, fill the Database and collection name to create a new database.

MongoDB Compass

Step 3: Finally, click on Create Database button to create the Database and collection.

MongoDB Compass

Drop a Database in Compass

Step 1: Click on the trash icon that will appear when you hover over the Database name, after that a confirmation dialog appears.

MongoDB Compass

Step 2: In the pop-up window, enter the name of the Database that you want to delete.

MongoDB Compass

Step 3: Finally, click Drop Database button to delete the Database you selected.

MongoDB Compass

Collections in MongoDB Compass

The Collection window displays the list of all the existing collection and views from the database you have selected. It includes all the name and other related information for the selected collection or view.

If you want to gain access to the collection of a database, click on the Database Name in the main Database view, or Click on the database in the left navigation pan.

MongoDB Compass

The collection window displays the information like - Collection name, number of documents, size, number of indexes, size of indexes, and Collation properties for the collection.

Create a Collection in MongoDB Compass

Step 1: Click on the Create Collection button.

MongoDB Compass

Step 2: After that, fill in the collection details in the Create Collection dialog.

MongoDB Compass

Step 3: Now, click on Create Collection to create the collection

MongoDB Compass

Drop a Collection

Step 1: In the collection window, click on the bin icon for the collection to delete. When you click on the trash icon, a dialog appears to ask your confirmation.

MongoDB Compass

Step 2: In the appeared pop-up dialogue, enter the name of the collection you want to delete from the database.

MongoDB Compass

Step 3: Finally, click on Drop Collection button to delete the collection.

MongoDB Compass

Managing Documents in MongoDB Compass

Documents are the records in a MongoDB collection. Documents are the basic unit of data in MongoDB. Using the document tab, we can perform the following tasks in our selected collection or view:

  • View the documents: The Document tab provides three ways to access document in MongoDB Compass.
    • List View - It is the default view of the Database in the MongoDB Compass. Document will be shown as individual members of the list. In the list view you can easily extend the embedded objects and arrays.
    • JSON View - In this view documents will be shown as completely-formatted JSON objects. In this view, MongoDB Compass use extended JSON to display the data-types of field where the correct data types are used.
    • Table View - The table view display documents as a table row. The document fields are shown as a column in the table. When we use table view, we can easily find out the documents that contains specific field values.
    We can use View buttons to select which view we want to use:
    MongoDB Compass
  • Insert the document: We can have two ways to insert documents into our collections:
    • JSON Mode: It allows you to write or paste JSON documents in the editor. You can use this mode to insert one or many documents at once as an array in the database.
    • Field-by-Field editor: You can create documents in more interactive way using this editor. It allows you to select all the field values and types. It supports only the insertion of a single document at a time.
  • Modify the document: You can update existing document in your collection. When you make changes to your document, the MongoDB Compass performs a findAndModify operation to update the existing document.
  • Clone the documents: You can insert new files and documents by cloning (i.e. by making an exact same copy of the document). You can copy the schema and values of an existing document/files in a collection.
  • Delete the documents: We can delete the document/file depending of the tab whether we are viewing our documents in List, JSON, or Table view.
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +