Skip to content

Commit 4831dc2

Browse files
authored
Merge pull request #25 from mongodb-developer/fix-genres
Fixed all code samples to use genres instead of genre.
2 parents 71d2dab + f34ce02 commit 4831dc2

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

docs/40-CRUD/1-WHERE.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ Now, translate the following into a MongoDB query.
151151
<TabItem value="javascript" label="JavaScript">
152152
<div>
153153
```js
154-
const cursor = await books.find( { "genre.name": "Science", pages: {$gt: 300} } );
154+
const cursor = await books.find( { "genres": "Science", pages: {$gt: 300} } );
155155

156156
await cursor.forEach((b) => {
157157
console.log(b);
@@ -162,7 +162,7 @@ Now, translate the following into a MongoDB query.
162162
<TabItem value="mongosh" label="mongosh">
163163
<div>
164164
```js
165-
db.books.find({ "genre.name": "Science", pages: {$gt: 300} });
165+
db.books.find({ "genres": "Science", pages: {$gt: 300} });
166166
```
167167
</div>
168168
</TabItem>

docs/40-CRUD/2-SELECT.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Here:
5858
## **Example 3: Using projection along with a query**
5959

6060
```js
61-
db.books.find({ "genre.name": "Science" }, { title: 1, totalInventory: 1, _id: 0 });
61+
db.books.find({ "genres": "Science" }, { title: 1, totalInventory: 1, _id: 0 });
6262
```
6363

6464
**Equivalent SQL query:**
@@ -111,7 +111,7 @@ Here:
111111
<TabItem value="javascript" label="JavaScript">
112112
<div>
113113
```js
114-
const cursor = await books.find({ "genre.name": "History" }).project( { _id: 0, authors: 0 } ).limit(10);
114+
const cursor = await books.find({ "genres": "History" }).project( { _id: 0, authors: 0 } ).limit(10);
115115

116116
await cursor.forEach((b) => {
117117
console.log(b);
@@ -122,7 +122,7 @@ Here:
122122
<TabItem value="mongosh" label="mongosh">
123123
<div>
124124
```js
125-
db.books.find({ "genre.name": "History" }, { _id: 0, authors: 0 });
125+
db.books.find({ "genres": "History" }, { _id: 0, authors: 0 });
126126
```
127127
</div>
128128
</TabItem>

docs/40-CRUD/3-ORDER-LIMIT.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ This fetches the **5 books with the highest stock**.
4040

4141
```js
4242
db.books
43-
.find({ "genre.name": "Fiction" }, { title: 1, pages: 1 })
43+
.find({ "genres": "Fiction" }, { title: 1, pages: 1 })
4444
.sort({ pages: -1 })
4545
.limit(10);
4646
```

docs/50-aggregation/7-merge.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ The `$merge` stage enables you to store aggregation results into a different col
4747

4848
## **🔹 Example 1: Creating a summary collection**
4949

50-
👉 Suppose we want to generate a collection that contains the **total number of books per genre**.
50+
👉 Suppose we want to generate a collection that contains the **total number of books per genre**. Using mongosh:
5151

5252
```js
5353
db.books.aggregate([
54-
{ $unwind: "$genre" },
55-
{ $group: { _id: "$genre.genreId", totalBooks: { $sum: 1 } } },
54+
{ $unwind: "$genres" },
55+
{ $group: { _id: "$genres", totalBooks: { $sum: 1 } } },
5656
{
5757
$merge: {
5858
into: "genre_summary",

0 commit comments

Comments
 (0)