Add your own data
B
Written by Bredagh Breslin
Updated over a week ago

Using the GUI, MongoDB Compass

Some users would rather work with a GUI to create and update their data and collections. The MongoDB GUI, Compass, offers additional functionality like data visualization and performance profiling as well as offering CRUD (create, read, update, delete) access to data, databases, and collections.

Prerequisites for using Compass with MongoDB Atlas

If you are using MongoDB Atlas, the steps to getting to Compass are as follows:

Prerequisites for using Compass with a self-managed MongoDB cluster

If you are using self-managed MongoDB:

  • Make sure the MongoDB self-managed cluster is installed and running on your machine or server

  • Make sure you have a database user on the MongoDB cluster you want to use Make sure you have MongoDB Compass installed on your computer. If not, download and install Compass for your operating system.

Creating a MongoDB database with Compass

The Databases tab in MongoDB Compass has a "Create Database" button.

alt text tbd

In MongoDB Compass, you create a database and add its first collection at the same time:

  • Click "Create Database" to open the dialog

  • Enter the name of the database and its first collection

  • Click "Create Database"

The next step is to insert one or more documents into your database.

Click on your database’s name to see the collection you created, then click on the collection’s name to see the Documents tab:

alt text tbd

Click the "Add Data" button to insert one or more documents into your collection.

You can add JSON documents one at a time, or add multiple documents in an array by enclosing comma-separated JSON documents in square brackets, as shown in this example:

[ { "_id" : 8752, "title" : "Divine Comedy", "author" : "Dante", "copies" : 1 }, { "_id" : 7000, "title" : "The Odyssey", "author" : "Homer", "copies" : 10 }, { "_id" : 7020, "title" : "Iliad", "author" : "Homer", "copies" : 10 }, { "_id" : 8645, "title" : "Eclogues", "author" : "Dante", "copies" : 2 }, { "_id" : 8751, "title" : "The Banquet", "author" : "Dante", "copies" : 2 } ]

Click "Insert to add" the documents to your collection.


Did this answer your question?