> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

# Set Which Fields Are Returned

MongoDB Compass Readonly Edition will be deprecated in a future release. To replicate the read-only behavior in a standard Compass edition, assign users [`read`](https://www.mongodb.com/docs/manual/reference/built-in-roles.md#mongodb-authrole-read) access at the database level and enable the [readOnly](https://www.mongodb.com/docs/compass/settings/read-only.md#std-label-compass-read-only) option in Compass.

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.

To set a projection:

1. In the Query Bar, click Options.

2. Enter the projection document into the Project field.

   To include fields:

   Specify the field name and set to `1` in the project document.

   **Example:**

   ```javascript
   { year: 1, name: 1 }
   ```

   Only the fields specified in the project document are returned. The `_id` field is returned unless it is set to  `0` in the Project document.

   To exclude fields:

   Specify the field name and set to `0` in the project document.

   **Example:**

   ```javascript
   { 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.

3. Click Find to run the query and view the updated results.

   **Note:**

   For query result sets larger than 1000 documents, Compass shows a subset of the results.  Otherwise, Compass shows the entire result set.

   For details on sampling, see [Sampling.](https://www.mongodb.com/docs/compass/sampling.md#std-label-compass-sampling)

## How Does the Compass Query Compare to MongoDB and SQL Queries?

[`$project`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/project.md#mongodb-pipeline-pipe.-project) corresponds to choosing specific fields to return in a SQL (Structured Query Language) `SELECT` statement.

**Example:**

You have 3,235 articles. You would like to see only the headlines and authors of those articles.

SQL

```sql
SELECT headline, author FROM article;
```

MongoDB Aggregation

```javascript
db.article.aggregate(
  { $project : { headline : 1, author : 1 } }
);
```

Compass Project Option

```javascript
{ headline : 1, author : 1 }
```

## Learn More

To learn how project works, see the `project` entry in the [MongoDB Manual.](https://www.mongodb.com/docs/manual/reference/method/db.collection.find.md#std-label-find-projection)
