Table of Contents
- 1.1 Welcome to Compass
- 1.2 What Compass can and cannot do
- 1.3 Navigating databases and collections
- 1.4 Browse documents in different views
- 1.5 Analyze data with Schema tab
- 1.6 Explore nested fields and arrays
- 1.7 Preview large collections
- 2.1 Introduction to the Query Bar
- 2.2 Combine filters with logical operators
- 2.3 Use projection to simplify results
- 2.4 Sort data for better analyses
- 2.5 Limit and paginate results
- 3.1 What Compass can (and cannot) do for updates
- 3.2 Edit fields in place
- 3.3 Add and remove fields
- 3.4 Edit nested fields with the JSON Editor
- 3.5 Backup and check for updates
- 4.1 Introduction: why data validation is important
- 4.2 Identify inconsistent values with the Schema tab
- 4.3 Find missing or null values with filters
- 4.4 Prepare clean datasets with filters and projections
- 4.5 Export data from Compass
1. Explore data with MongoDB Compass
Module duration: 16m 41s
1.1 Welcome to Compass
Scenario context
Imagine you work as a data analyst for a movie streaming service. Your team wants to explore information about movies, theaters, and customer reviews to better understand what audiences enjoy and how they interact with content. This is precisely where MongoDB Compass comes in.
What is MongoDB Compass?
MongoDB Compass is a graphical user interface (GUI) for MongoDB. It allows you to explore and analyze data visually, without having to write code immediately. It is the ideal tool for data analysts, developers and administrators who want to inspect their database intuitively.
Connecting to a cluster
When Compass starts, the first screen displayed is the connection screen. This is where we tell Compass which MongoDB deployment we want to explore.
Connection steps:
- Click on Add new connection
- In the dialog that opens, notice the Connection String field at the top — this is the address Compass uses to connect to the database
- If we use MongoDB Atlas, the connection string is in the cluster. Atlas even offers a Copy for Compass option to directly paste this string
For this course: A free Atlas cluster has been configured, with the MongoDB sample datasets loaded. One of these databases is called sample_mflix. It contains:
- Movie data
- Comments
- Information on cinemas
- User accounts (
users)
Interface overview
After logging in and clicking on the movies collection, the main workspace displays a sample of documents. Each document is a movie recording with fields like title, year, cast, and even IMDb ratings.
Above the documents, there are several important tabs:
| Tab | Role |
|---|---|
| Documents | Shows raw data |
| Diagram | Summarizes field structure — useful for spotting data types and distributions |
| Indexes | Provides performance information, showing which fields are indexed |
At the top of the screen is a search bar (query bar) where you can write queries to filter and analyze the data more precisely.
In just a few clicks, Compass allows you to connect to the cluster, explore databases and start analyzing documents.
1.2 What Compass can and cannot do
The strengths of Compass
Compass is above all an exploration and analysis tool. It is excellent for:
- Browse documents
- Inspect schemas
- Build visual filters
- Execute fast ad hoc queries
- Create and delete databases and collections
- Insert individual documents
- Correct a field or two when an error is found
For example, by opening a movie recording and hovering over a field, one can click on it, change the title or update a note, then save the document. This is perfect for one-off fixes or testing a change on a single recording.
The limits of Compass
Compass is not a complete database management environment. It is important to set expectations:
| Limitation | Explanation |
|---|---|
| No mass updates | You cannot run an update that changes thousands of documents at once. For this type of operation, you must use the MongoDB shell (mongosh), a MongoSH client, or an application driver |
| No scripted queries or stored procedures | Compass allows you to construct filters and aggregations visually, but it does not run JavaScript or server-side scripting. If one needs loops, conditional logic or scheduled operations, it is beyond the scope of Compass |
| Limited automation | You can insert or delete individual documents, but there is no way to trigger actions, create triggers or schedule tasks from the interface |
What can be changed in the interface
- Documents tab: inline editing option for one record at a time
- Schema and Index tabs: read only — you can analyze and visualize, but not modify the data directly
- Aggregations tab: powerful for analysis, it allows you to build pipelines and see the results, but does not save changes in the collection
Think of Compass as a data microscope — perfect for inspecting, exploring, and learning from your data, but not for performing large-scale operations or updates in production.
1.3 Navigate databases and collections
Interface structure
Compass organizes everything into databases and collections, and the left sidebar is the main roadmap. Each top-level element is a database — a container of related data. Inside each database are one or more collections, which contain the actual documents.
For those who come from a relational context: a database ≈ a schema/catalog, a collection ≈ a table, a document ≈ a line.
Navigate the sidebar
Example with sample_mflix:
- Click on the arrow to expand the
sample_mflixdatabase - See the collections appear:
movies,comments,theaters,users, and others - Click on a collection (e.g.
movies) to open it in the main workspace — you can then browse documents, build filters or switch to schema view - To reduce the database, click on the arrow again
Navigation between several databases:
- Compass displays all databases present in the cluster (e.g. Airbnb samples, supplies samples)
- We can expand these databases and quickly switch between collections like
listings,reviews,salesorproductswithout opening new windows - The sidebar remains visible regardless of the active tab — so you can dive into a collection, browse documents, then move to another database with a single click, without having to go back
On larger deployments, the sidebar becomes the best ally. It allows you to know where you are, reduce unnecessary sections and move easily between different databases and collections.
1.4 Browse documents in different views
The three views available
Compass offers several ways to visualize data, each with its own strengths depending on what you want to see. To access it, use the buttons at the top of the workspace.
1. List View (default view)
Each document is displayed as an organized map. This view is ideal for:
- A quick scan
- Easily read fields like
name,email, orpreferenceswithout worrying about formatting
2. JSONView
Each document is displayed in JSON format exactly as it is stored in MongoDB. Features:
- Expand or collapse nested fields
- View data types
- Understand the precise structure of each document
- Particularly useful for understanding how arrays or embedded objects are organized
3. Table View
Flattens documents into a grid, with each field as a column and each document as a row. This view facilitates:
- Scanning a specific field across many records
- Comparing values like customer emails, product names or numeric values at a glance
Important: The three views — List, JSON, and Table — are just different lenses for the same data. You can switch from one to the other at any time without modifying the underlying documents.
1.5 Analyze data with Schema tab
What is the Schema tab?
Compass includes a Schema tab that automatically analyzes an entire collection and summarizes its structure. This is a powerful way to understand what fields exist, the types of data they contain, and how the values are distributed.
Access: movies collection → Schema tab (next to Documents and Indexes)
Compass immediately begins sampling documents to build a profile of the collection.
What the Schema tab shows
- List of all detected fields with the percentage of documents that contain each
- Data type identification for each field (string, number, date, array, etc.)
- Distribution of values in the form of graphs
Example with the year field:
Compass displays a distribution of values — one can instantly see which decades have the most films represented. It’s a quick way to spot trends, like a high concentration of titles from the 1990s through the 2000s.
Example with the imdb.rating field:
Compass visualizes how the notes are distributed in the dataset. It can be noticed that many films cluster in the 6-7 range, while only a handful reach 9 or higher. This type of chart gives an immediate view without having to write a single query.
Inconsistency detection
The Schema tab is excellent for spotting inconsistencies. For example, if most notes are stored as numbers but a few appear as strings, Compass reports both types and displays their percentages. These mixed types can cause problems in queries or aggregations.
The analysis is based on a sample of documents. For a very large collection, you can increase the sample size for a more precise image.
The Schema tab is like an instant health check of your data — it shows what fields exist, what types they use, and how the values are distributed, all without writing a single line of code.
1.6 Explore nested fields and arrays
The power of nested documents in MongoDB
One of the strengths of MongoDB is that a single document can contain nested objects and arrays. These structures allow complex real-world data to be captured in a single record.
Exploring arrays
In the movies collection, when expanding a document, we see fields like cast and genres with brackets around their values — these brackets indicate an array. Arrays can contain lists of strings, numbers, and even entire documents.
Example: Clicking on the arrow next to cast shows a list of actors stored as strings, all in the same document. This allows you to capture many values — such as a full distribution — without spreading the data across multiple tables.
Exploration of embedded objects
The imdb field is an embedded object. Expanding it, we see nested fields like rating, votes, and id. Each is part of the imdb object, but remains linked to the same movie record.
Arrays and embedded objects can go to several depth levels. For example, opening the tomatoes field reveals another object with its own nested properties, such as review scores and viewer scores. Compass allows you to dig layer by layer.
Schema view for nested fields
Switching to the Schema tab, Compass summarizes these nested fields in the same way as top-level fields:
- Distribution for tables like
genres(e.g. how many films are in the action, drama or comedy category) - Numerical distributions for fields like
imdb.rating
Instead of spreading details across multiple tables, everything about a film — its cast, its ratings, its reviews — is stored together. Compass gives the tools to visually navigate this hierarchy, without writing a single query.
1.7 Preview large collections
Compass behavior with large collections
Real-world databases often contain tens of thousands of documents. Compass is designed to provide fast and secure access to this data without overloading the machine or the cluster.
Demonstration with the comments collection in sample_mflix:
As soon as the page loads, Compass displays a sample of documents rather than trying to retrieve everything at once. A small counter indicates how many documents are currently displayed — which keeps performance smooth, even if the collection is massive.
Infinite scroll
When scrolling through the results, Compass loads documents by pages. Upon reaching the end of the visible list, it automatically fetches the next batch. This infinite scrolling allows you to navigate deeper into the dataset without running a heavy query on the entire collection.
Important points
- What we see is a read-only preview. If all documents are necessary for an analysis, you must write a query or export the data
- You can still filter or sort while browsing — for example, type a query to return only comments from a specific user, and Compass will apply that filter to each page as you scroll
- This approach gives the best of both worlds: immediate visibility into the data structure, and the ability to spot patterns or anomalies without the risk of accidentally importing millions of records
Compass allows you to connect to a database, navigate collections, explore nested fields, analyze schemas, and securely preview even the largest datasets — without writing a single line of code.
2. Filter, project and sort data
Module duration: 9m 10s
2.1 Introduction to the Query Bar
Why the Query Bar?
When working with large collections, seeing everything at once can be overwhelming. That’s why MongoDB Compass includes a query bar — a simple but powerful way to control what’s displayed on the screen, without writing shell commands or scripts.
The components of the Query Bar
Depending on the version of Compass, the query bar can include several fields:
| Field | Description |
|---|---|
| Filter | To reduce results according to conditions |
| Project | To control which fields are displayed |
| Fate | To control the order of results |
| Limit | To control how many documents Compass loads at a time |
Practical example — Projection
Scenario: An analyst prepares a list of marketing contacts. It only needs the customers name and email address, not all other fields.
In the Project field of the query bar:
{ "name": 1, "email": 1 }
After clicking Find, Compass refreshes the results and only displays _id, name and email. All additional fields (movie, _id, text, date) disappear from view.
Practical example — Sort
To see the most recent entries first, in the Sort field:
{ "date": -1 }
After clicking Find, the results are sorted by date, from newest to oldest.
Practical example — Limit
To control how many records Compass loads at a time (ex. 20), in the Limit field:
20
Even without filters, projection, sorting, and limiting give analysts an easy way to focus on key fields, control the order of results, and keep datasets manageable when exploring.
2.2 Combine filters with logical operators
Why logical operators?
Filtering by a single condition is useful, but most real-world questions are a bit more complex. We sometimes want to search on several fields or match several different criteria at the same time. This is where MongoDB’s logical operators like $or and $and come in.
The $or operator
Scenario: The analyst wants to see comments from users with Gmail or Yahoo addresses. This could be part of a campaign targeting users on major email providers.
Filter in the query bar:
{ "$or": [ { "email": /gmail\.com/ }, { "email": /yahoo\.com/ } ] }
$or takes an array of conditions — if any of them is true, the document is returned.
After clicking Find, Compass only displays comments where the email address matches Gmail or Yahoo.
Combine $or and $and
Extended scenario: In addition to the email condition, the analyst wants to focus on recent comments — those posted on or after January 1, 2020.
When multiple conditions are listed at the same level in a query, MongoDB treats them as an implicit $and — both parts must match:
{
"$or": [ { "email": /gmail\.com/ }, { "email": /yahoo\.com/ } ],
"date": { "$gte": { "$date": "2020-01-01T00:00:00Z" } }
}
Result: Compass only displays the subset of documents whose email address is Gmail or Yahoo AND whose comment was posted on or after January 1, 2020. The document counter at the top reflects the filtered set, making it easy to check the results.
This combination of
$orand$andprovides a lot of flexibility — it’s how you go from simple searches to targeted real-world queries.
2.3 Use projection to simplify results
What is projection?
In the comments collection, for example, each record includes: _id, the name of the commenter, an email, a reference to a movie, a comment text, and a timestamp. It’s comprehensive, but it can be overwhelming when you’re trying to focus on something specific.
The projection (projection) provides a way to control which fields Compass displays in the results. It’s like hiding unnecessary columns in a spreadsheet — the data is still there, but we focus on the fields that really interest us.
Projection syntax
In the Project field of the query bar, we enter a JSON object with 1 to include a field and 0 to exclude it.
Example: Building a simple contact list with only name and email:
{ "name": 1, "email": 1 }
Result after Find: Compass refreshes the display and shows a clean, focused view — just _id, name and email. Even though other fields like text and movie_id are still stored in the database, they are hidden from view.
Advantages of projection
- Focus on key fields when validating data
- Reduce clutter when scanning records for issues
- Prepare exactly the dataset you need to export
- With very large datasets, this focused view can make Compass smoother and ease the mental load
Projection is particularly useful when preparing data for exports or quick reviews. Instead of running through a wall of fields, we keep things clear and intentional.
2.4 Sort data for better analyzes
The usefulness of sorting
When working with a large collection, the order in which documents appear can reveal a lot of useful information. Sorting brings the most relevant records to the top — whether they’re the most recent entries, the largest values, or something else important.
Sort syntax
In the Sort field of the query bar, Compass expects a valid JSON object, as for projection:
| Value | Meaning |
|---|---|
1 | Ascending order |
-1 | Descending order |
Examples:
Sort by date descending (most recent comments first):
{ "date": -1 }
Sort by ascending date (oldest comments first):
{ "date": 1 }
Sorting on multiple fields
You can sort on several fields. For example, sort first by descending date, then by email alphabetically:
{ "date": -1, "email": 1 }
This is useful when several documents have the same date and you want a consistent order in the results.
Interaction with projection
Sorting works transparently with projection. For example, if we have already narrowed down the results to name and email, sorting applies on top of that view, helping to focus on the data in a meaningful order without unnecessary clutter.
2.5 Limit and paginate results
Why limit and paginate?
Even if we’ve simplified the view with projection or sorted the data to bring the most important records to the top, scrolling through everything can still be overwhelming. This is where limitation and pagination come into play.
Use Limit field
In the Limit field of the query bar, enter 20, then click Find.
Compass now displays only the first 20 matching documents. Everything else is still in the database, but it hasn’t been loaded into the view. This makes the interface faster and easier to read.
Combine Limit, Throw and Spell
These three features work perfectly together:
- Project only
nameandemailto simplify the view - Sort by
dateto bring the most recent comments first - Limit to 20 to focus on a clean, predictable slice of data
// Filter : {}
// Project : { "name": 1, "email": 1 }
// Sort : { "date": -1 }
// Limit : 20
This combination is incredibly useful when exploring a dataset, preparing a report, or simply staying oriented when the collection gets too large.
3. Update documents in Compass
Module duration: 10m 12s
3.1 What Compass can (and cannot) do for updates
Philosophy of updates in Compass
Before you begin making changes to the data, it is important to understand what MongoDB Compass can and cannot do when it comes to updates. Compass is great for quick, targeted edits, but it is not a mass data cleansing tool.
What Compass enables
- Make small surgical changes when you need to correct or adjust a single document
- Edit one document at a time via the online editor
Scenario: The analyst finds a typo in a commenter’s email address — something that could cause problems when contacted later. Rather than writing a full query or script, it just wants to fix this record directly.
Access to the inline editor
Each document in the list has a small pencil icon (depending on the Compass version), or one can simply click on the record. This is the Edit document option. When hovering over a record, the icon appears in the upper right corner of the card. By clicking, an inline editor opens where you can modify any field.
What Compass does NOT allow
Notice what is not present in the interface:
- No Select All
- No Bulk Update
- No Multiple Edit
Compass intentionally keeps updates focused on changes to a single record to reduce the risk of accidental large-scale changes.
Suitable use cases
- Correct a typo in an email
- Correct a missing value
- Adjust a small error in a field like a date or name
For larger changes, like cleaning thousands of records, you should use the MongoDB shell or a script, but not Compass. Compass is the fine brush, not the paint roller — for precision edits, not mass operations.
3.2 Edit fields in place
Direct editing in the interface
One of the nicest features of MongoDB Compass is how easy it is to correct small errors without ever leaving the interface. Even if we just need to correct a single value in a single document, we can do it directly — without scripts, without queries, without the command line.
Editing process
Scenario: The analyst notices that a location field in a comment says NYC, but for reporting consistency it should say New York.
Steps:
- Make sure you are in the Documents tab
- Switch to Table View — this view is particularly convenient for quick edits because each field is laid out in a row/column format, like a spreadsheet
- Hover over the
locationcell in this record — a small pencil icon appears (or click directly on the record) - An inline editor for this field appears
- Edit the text directly — here, replace
NYCwithNew York - Press Enter or click Update
Compass immediately saves the change to the database. No need to re-run a query or refresh the view — the update is applied in place.
Common use cases
- Correct a typo in a name, city, address, email
- Expand an abbreviation
- Update a single date or status field
Warning: Compass updates the database live as soon as you save. It is therefore advisable to be deliberate when editing fields in this way.
3.3 Add and remove fields
Modify the structure of a document
Changing values is one thing, but sometimes you need to adjust the structure of the document itself. Maybe a piece of data is completely missing, or maybe there is a field that is no longer needed. MongoDB Compass makes it simple to add and remove fields directly from the interface.
Add new field
Scenario: The analyst reviews a customer record in the comments collection and notices that there is no phone_number field. To keep the contact information consistent, he decides to add one.
Steps:
- Hover over the document to update and click on the Edit document icon (pencil)
- An inline JSON editor opens, showing the entire structure of this record
- Click on Add field
- Type the field name:
phone_number - Enter the value (ex.
555-123-4567) - Click on Update
Compass saves the change, and the new field becomes part of the document.
Delete an existing field
Scenario: There is a field that we no longer need, such as an old alias (nickname).
Steps:
- In the same editor, hover over the
nicknamefield - Click on the trash icon
- Compass marks the field for deletion
- Click on Update — the field disappears entirely from the document
Common uses
- Fill in missing information without writing an
updatestatement - Clean up obsolete or incorrect fields
- Keep document structure organized and consistent
These modifications are direct. As soon as you save, you update the actual document in the database.
3.4 Edit nested fields with the JSON Editor
Working with nested data
Not all documents are flat. One of the strengths of MongoDB Compass is the way it handles nested data — arrays and embedded objects. Sometimes the only way to correct a problem is to directly edit one of these nested fields.
Example with the movies collection
Each movie has a tomatoes field, and inside is a nested viewer object which contains a rating and numReviews field. If an analyst spots an incorrect note (perhaps a data entry error or a timing issue), they can correct it directly in Compass.
Steps:
- Open the
moviescollection - Find a record with value
tomatoes.viewer.rating - Click to edit the document
- Switch from visual editor to JSON editor view — this mode displays the entire document in raw JSON format, including all nested structures
- Scroll to the
tomatoesfield, then toviewer, and find theratingproperty - Modify the value (e.g. change
3.5to4.2)
Real-time validation: Because it’s raw JSON, Compass checks the syntax in real-time. If one makes a typo (forgetting a comma or breaking a bracket), it highlights the problem immediately with a red underline. This avoids saving invalid JSON by accident.
- Once the update appears correct, click Update
Compass saves the change to the database, and the new note is immediately reflected in the document.
What this process does
- Modify numbers inside nested objects (like we just did)
- Update array elements (e.g. adjust an entry in the
genresorcastarrays) - Make several small changes inside a complex structure without running a single query
This is an accurate and secure way to work with deeply nested data. And because Compass doesn’t allow invalid JSON to be saved, it also protects against syntax errors.
3.5 Backup and check for updates
Confirm changes
Once you have made a change in MongoDB Compass, it is important to confirm that the update has been saved in the database. Remember that Compass doesn’t just display a temporary view — each modification we make is applied directly to the live document in the collection.
Verification process
Continuation of the previous example: After clicking on Update for the tomatoes.viewer.rating rating, the modification is saved in the database. Here’s how to check:
- Click the Refresh button at the top of the Documents tab
- This tells Compass to re-fetch the document directly from the server, ensuring that we don’t see a cached version
- When the list reloads, scroll to the same record
- The
tomatoes.viewer.ratingrating now displays the corrected value
Why this check is important
- Confirm that the changes have been saved
- Ensure you are viewing the most recent data from the cluster
- Help detect accidental typos before they slip into reports or downstream processes
This same step works whether you’ve corrected a single text field, added or deleted an entire field, or updated something in a deeply nested structure. Getting into the habit of saving and checking saves a lot of headaches.
4. Prepare and validate data
Module duration: 9m 40s
4.1 Introduction: Why Data Validation is Important
Data quality first
Before data arrives in a report, dashboard or marketing campaign, it must be clean, consistent and reliable. Even the best visualization or analysis will be of no use if the underlying data is unreliable. This is why data validation is so important — it’s not just a technical step; it’s about ensuring that the story we tell with the data is accurate.
Practical scenario
The analyst prepares a customer dataset for a new marketing campaign. It wants to segment users by location, email domain, and registration date. On the surface, all the information appears to be there, but before using this data, you need to make sure it holds up.
Common problem types
| Problem | Description | Impact |
|---|---|---|
| Missing fields | Fields completely absent in certain documents | Creates gaps in analysis |
| Inconsistent values | Ex. New York City vs NYC for the same city | Breaks aggregations and segmentations |
| Outliers | Ex. a very distant date in the past | Falsify statistical analyzes |
| Incorrect email addresses | Invalid or poorly formatted emails | Causes problems during shipments |
| Mixed data types | Ex. some rating in number, others in string | Breaks queries and dashboards |
The purpose of validation in Compass
The goal is not to clean up everything in Compass — it’s to detect problems early and make informed decisions about what needs to be fixed, normalized, or rejected.
Concrete example: If half of the location values say NYC and the other half say New York, this is a major problem. In a campaign targeting customers in New York, inconsistent data could mean that some people aren’t receiving the emails they should have, and this will break future aggregations.
What to cover
- Inspect fields for consistency
- Check data types and value ranges
- Identify anomalies or missing data
- Build confidence that what we analyze or export is solid
4.2 Spot inconsistent values with the Schema tab
The Schema tab as a data quality tool
One of the quickest ways to check data quality is to let Compass do some of the work. The Schema tab is designed for exactly this — it automatically samples the collection, scans each field, and summarizes what it finds. If something is wrong, it usually shows up here first.
Example with the date field
Collection: customers (example in this module)
What we want to see: This field should store appropriate timestamps. In a clean dataset, Compass confirms this by displaying a single bar labeled date — on hover, we see 100%. This means that this field will behave correctly when sorting, filtering or exporting data.
What we would see with a less clean dataset:
We might see several bars — one for date, another for string — indicating that certain values were stored in plain text (like "2025-05-01"). For example: 80% date, 20% string → two bars.
Consequences of mixed types
When fields contain mixed types, this can:
- Fail or ignore records in queries
- Sort values in charts incorrectly
- Completely misalign dates in exports
Good practice
- Compass also shows the frequency of each type, allowing you to quickly assess the extent of the problem
- If unsure of data quality, analyze several times (click Analyze again) to see if different samples give different results
- 100% consistency after multiple scans is a good sign
The Schema tab is your early warning system. It helps confirm that key fields are consistent before performing further validation.
4.3 Find missing or zero values with filters
The impact of missing values
Missing or incomplete records can silently break reports, campaigns or dashboards. A single critical field — like an email address — missing from just a few documents can mean customers are excluded from a communication or analysis.
Visual detection via Schema tab
Even without running a query, MongoDB Compass makes it easy to spot these issues visually through the Schema tab.
Collection: comments
Each record includes an email field, important for building a list of marketing contacts. If this field is missing or set to null in some records, be aware.
Process:
- Open the Schema tab
- Compass scans the collection and lists all fields with their distributions
- Scroll to the
emailfield
What we see:
- If each record has a valid email value → only one type (usually
string) - If some records are missing or contain nulls → multiple types in the summary:
Stringfor most recordsMissing FieldorNullfor the rest
This immediately indicates the presence of incomplete records.
Information available
- Number and percentages of occurrences of each type/state
- Example values by clicking on the field — easy to spot gaps at a glance
Advantages of this approach
- Fast and visual
- Does not require queries
- Ideal for checking data completeness as part of a validation workflow
4.4 Prepare clean datasets with filters and projections
The goal of preparation
When preparing data for a report, dashboard or campaign, it is often best to reduce it to only what matters. Even without running queries directly, we can use projection to clean up what we see and keep the dataset focused.
Scenario
The analyst has already reduced the data to active customers in California or New York through an upstream process (perhaps from a saved view, a pre-filtered collection, or a previous export). Now, in Compass, the goal is to simplify what we see to work only with the necessary fields.
In the Project field of the query bar:
{ "name": 1, "email": 1 }
Result after Find:
Compass refreshes the view and only shows three fields: _id, name and email. Everything else — additional attributes, metadata, and fields that don’t matter to this campaign — is hidden from view.
Uses of this projection
- Focus on key fields when validating data
- Reduce clutter when scanning records for issues
- Make sure to prepare exactly the dataset you need to export
Even without filtering, the projection gives control over the shape of the dataset. And if the team uses collection filters or aggregation pipelines upfront, projecting in Compass is a clean way to validate the final structure before sending it elsewhere.
4.5 Export data from Compass
The last step: export
Once the data is cleaned and formatted, the final step is to extract it from Compass for use elsewhere — in a spreadsheet, reporting tool, or by another team. MongoDB Compass makes this easy with its built-in export functionality.
Even if you don’t directly apply filters in Compass, you can still export exactly what is displayed on screen, including the applied projections.
Export process
Scenario: The analyst has prepared a simple dataset displaying only the name and email fields for specific customers in California and New York. Now it’s time to pass this list to the marketing team.
Steps:
- Click on the Export collection icon
- Select Export the full collection or Export query results, depending on whether you formatted the view with projections
- Compass gives the choice between exporting in CSV or JSON
Selection of format:
- CSV: easy to open in a spreadsheet tool like Excel or Google Sheets
- JSON: ideal for use programmatically or in another system
- Compass will export exactly what is on screen, including collapsed fields
- Save the file and open it in a spreadsheet program
Result: A clean, focused dataset showing only customer names and email addresses — no clutter, no extra fields, just what the marketing team needs.
Advantages of the export process
- Fast and reliable for sharing curated datasets with other teams
- Useful when you need to run an analysis in a tool outside of Compass
- Allows quick saving of a formatted view without writing a script
This export process completes the complete cycle: exploring the data, validating it, formatting it, and finally extracting it for use in reports, campaigns or external analyses.
5. General Summary
This training covers the use of MongoDB Compass as a tool for exploring and modifying data in an analysis context. Here are the key points to remember:
What MongoDB Compass can do
| Feature | Description |
|---|---|
| Connecting to a MongoDB Atlas cluster | Via a string connection |
| Navigation in databases and collections | Via the left sidebar |
| Viewing of documents | In List View, JSON View or Table View |
| Analysis of the schema | Field distribution, data types, outliers |
| Exploration of nested data | Arrays and embedded objects, hierarchical navigation |
| Filtering of data | With the query bar ($or, $and, comparison operators) |
| Projection of fields | Show only relevant columns |
| Sorting results | Ascending or descending, on one or more fields |
| Limitation of results | Load only N documents at a time |
| Modification of documents | Inline editing of one document at a time |
| Add/delete fields | Via the inline editor with the Add field / trash icon |
| JSON modification of nested fields | Via the JSON Editor with real-time syntactic validation |
| Validation of data quality | Via Schema tab and mixed types detected |
| Export of data | In CSV or JSON from the interface |
What MongoDB Compass CANNOT do
- Bulk updates on several thousand documents
- Executing server-side JavaScript scripts
- Creating triggers or scheduled tasks
- Automated maintenance operations
Database used in this course
sample_mflix — Sample MongoDB dataset containing:
movies: movie recordings withtitle,year,cast,genres,imdb,tomatoescomments: user comments withname,email,movie_id,text,datetheaters: information on cinemasusers: user accounts
Key MongoDB operators seen in this course
| Operator | Type | Usage |
|---|---|---|
$or | Logic | At least one condition must be true |
$and | Logic | All conditions must be true (implicit when multiple conditions at the same level) |
$gte | Comparison | Greater than or equal to |
1 | Screening | Include field |
-1 | Spell | Descending order |
Search Terms
query · modify · data · mongodb · compass · nosql · databases · sql · projection · schema · fields · tab · limit · nested · process · export · field · interface · practical · sort · advantages · bar · cannot · collections