Skip to content

Commit 79c6424

Browse files
authored
Merge pull request #17 from Meg528/patch-9
Update 3-project.mdx
2 parents 9d40194 + 6f347c0 commit 79c6424

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

docs/30-simple-queries/3-project.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ A document from the `books` collection looks like:
5959
}
6060
```
6161

62-
If we're interested just in the titles, we can use `$project` to select just the fields we're interested in. As an example, to get just the book's title and year we'll write:
62+
If we're interested in the titles, we can use `$project` to select just the fields we're interested in. As an example, to get just the book's title and year, we'll write:
6363

6464

6565
<Tabs groupId="aggregations">
@@ -81,9 +81,9 @@ db.books.aggregate([{$project: {title: 1, year: 1}}])
8181
</Tabs>
8282

8383

84-
- 1 means "show that field"
85-
- 0 means "hide that field"
86-
- the primary key `_id` field is shown by default
84+
- 1 means "show that field."
85+
- 0 means "hide that field."
86+
- The primary key `_id` field is shown by default.
8787

8888
So we can exclude fields and show all fields except `attributes` using:
8989

@@ -132,7 +132,7 @@ db.books.aggregate([{$project: {title: 1, cover: 1}}])
132132

133133
## Excluding fields
134134

135-
👐 Exclude the `cover`, `attributes` and `_id` fields from the result.
135+
👐 Exclude the `cover`, `attributes`, and `_id` fields from the result.
136136

137137
<details>
138138
<summary>Answer</summary>
@@ -163,7 +163,7 @@ db.books.aggregate([{$project: {_id: 0, attributes: 0, cover: 0}}])
163163

164164
:::danger
165165

166-
You can't include and exclude fields in the same projection: if you start including, you must keep including and vice versa.
166+
You can't include and exclude fields in the same projection. If you start including, you must keep including, and vice versa.
167167

168168
:::
169169

@@ -183,4 +183,4 @@ The only exception to this rule is the `_id` field, which we can exclude in an i
183183

184184
```js
185185
db.books.aggregate([{$project: {title: 1, _id: 0}}])
186-
```
186+
```

0 commit comments

Comments
 (0)