Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/40-CRUD/1-WHERE.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Now, translate the following into a MongoDB query.
<TabItem value="javascript" label="JavaScript">
<div>
```js
const cursor = await books.find( { "genre.name": "Science", pages: {$gt: 300} } );
const cursor = await books.find( { "genres": "Science", pages: {$gt: 300} } );

await cursor.forEach((b) => {
console.log(b);
Expand All @@ -162,7 +162,7 @@ Now, translate the following into a MongoDB query.
<TabItem value="mongosh" label="mongosh">
<div>
```js
db.books.find({ "genre.name": "Science", pages: {$gt: 300} });
db.books.find({ "genres": "Science", pages: {$gt: 300} });
```
</div>
</TabItem>
Expand Down
6 changes: 3 additions & 3 deletions docs/40-CRUD/2-SELECT.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Here:
## **Example 3: Using projection along with a query**

```js
db.books.find({ "genre.name": "Science" }, { title: 1, totalInventory: 1, _id: 0 });
db.books.find({ "genres": "Science" }, { title: 1, totalInventory: 1, _id: 0 });
```

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

await cursor.forEach((b) => {
console.log(b);
Expand All @@ -122,7 +122,7 @@ Here:
<TabItem value="mongosh" label="mongosh">
<div>
```js
db.books.find({ "genre.name": "History" }, { _id: 0, authors: 0 });
db.books.find({ "genres": "History" }, { _id: 0, authors: 0 });
```
</div>
</TabItem>
Expand Down
2 changes: 1 addition & 1 deletion docs/40-CRUD/3-ORDER-LIMIT.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ This fetches the **5 books with the highest stock**.

```js
db.books
.find({ "genre.name": "Fiction" }, { title: 1, pages: 1 })
.find({ "genres": "Fiction" }, { title: 1, pages: 1 })
.sort({ pages: -1 })
.limit(10);
```
Expand Down
6 changes: 3 additions & 3 deletions docs/50-aggregation/7-merge.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ The `$merge` stage enables you to store aggregation results into a different col

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

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

```js
db.books.aggregate([
{ $unwind: "$genre" },
{ $group: { _id: "$genre.genreId", totalBooks: { $sum: 1 } } },
{ $unwind: "$genres" },
{ $group: { _id: "$genres", totalBooks: { $sum: 1 } } },
{
$merge: {
into: "genre_summary",
Expand Down