Skip to content

Commit fdf1067

Browse files
Merge pull request #13 from Meg528/patch-20
Update 7-CREATE-VIEW.mdx
2 parents 21696f9 + 87c5560 commit fdf1067

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

docs/50-aggregation/7-CREATE-VIEW.mdx

+9-9
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ In MongoDB, the **$merge** stage allows you to **write the results of an aggrega
88

99
The `$merge` stage enables you to store aggregation results into a different collection. If the target collection doesn’t exist, MongoDB will create it automatically.
1010

11-
### **Key Features:**
11+
### **Key features:**
1212

13-
✔️ Inserts new documents if they don’t exist.
14-
✔️ Updates existing documents based on `_id` or a specified field.
15-
✔️ Can replace, merge, or discard duplicate records.
16-
✔️ Useful for **ETL workflows, reporting tables, and maintaining summary data.**
13+
✔️ Inserts new documents if they don’t exist
14+
✔️ Updates existing documents based on `_id` or a specified field
15+
✔️ Can replace, merge, or discard duplicate records
16+
✔️ Useful for **ETL workflows, reporting tables, and maintaining summary data**
1717

1818
---
1919

@@ -42,7 +42,7 @@ The `$merge` stage enables you to store aggregation results into a different col
4242

4343
---
4444

45-
## **🔹 Example 1: Creating a Summary Collection**
45+
## **🔹 Example 1: Creating a summary collection**
4646

4747
👉 Suppose we want to generate a collection that contains the **total number of books per genre**.
4848

@@ -61,7 +61,7 @@ db.books.aggregate([
6161
]);
6262
```
6363

64-
### **Equivalent SQL Query**
64+
### **Equivalent SQL query**
6565

6666
```sql
6767
INSERT INTO genre_summary (genre, totalBooks)
@@ -72,7 +72,7 @@ ON DUPLICATE KEY UPDATE totalBooks = VALUES(totalBooks);
7272

7373
---
7474

75-
## **🔹 Example 2: Maintaining an Author Summary Table**
75+
## **🔹 Example 2: Maintaining an author summary table**
7676

7777
👉 We want to create an **author_stats** collection with the total number of books written by each author.
7878

@@ -91,7 +91,7 @@ db.books.aggregate([
9191
]);
9292
```
9393

94-
### **SQL Equivalent**
94+
### **SQL equivalent**
9595

9696
```sql
9797
INSERT INTO author_stats (authorName, totalBooks)

0 commit comments

Comments
 (0)