If the query bar displays the Project option, you can specify which fields to return in the resulting data. By default, all fields are returned.
Set a Projection
In Atlas, go to the Data Explorer page for your project.
If it's not already displayed, select the organization that contains your project from the Organizations menu in the navigation bar.
If it's not already displayed, select your project from the Projects menu in the navigation bar.
In the sidebar, click Data Explorer under the Database heading.
The Data Explorer displays.
Note
You can also go to the Clusters page, and click Data Explorer under the Shortcuts heading.
Set the projection.
Select the collection.
In the Query Bar, click Options.
Enter the projection document into the Project field.
To include fields:
Specify the field name and set to
1in the project document.Example
{ year: 1, name: 1 } Only the fields specified in the project document are returned. The
_idfield is returned unless it is set to0in the Project document.To exclude fields:
Specify the field name and set to
0in the project document.Example
{ year: 0, name: 0 } All fields except for the fields specified in the project document are returned.
As you type, the Find button is disabled and the Project label turns red until a valid query is entered.
Click Find to run the query and view the updated results.
Note
For query result sets larger than 1000 documents, Atlas shows a subset of the results. Otherwise, Atlas shows the entire result set.
For details on sampling, see Sampling.
How Does the Atlas Query Compare to MongoDB and SQL Queries?
$project corresponds to choosing specific fields to return
in a SQL SELECT statement.
Example
You have 3,235 articles. You would like to see only the headlines and authors of those articles.
- SQL
SELECT headline, author FROM article; - MongoDB Aggregation
db.article.aggregate( { $project : { headline : 1, author : 1 } } ); - Atlas Project Option
{ headline : 1, author : 1 }
Learn More
To learn how project works, see the project entry in the
MongoDB Manual.