Skip to content

Commit 93d38ac

Browse files
Merge pull request #9 from Meg528/patch-12
Update 2-match-project.mdx
2 parents 07426cb + a6f5bde commit 93d38ac

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

docs/50-aggregation/2-match-project.mdx

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# 👐 $match and $project
22

3-
MongoDB’s **Aggregation Framework** allows for powerful data transformations and analysis. The **$match**, **$project** & **$sort** stages are fundamental building blocks of an aggregation pipeline.
3+
MongoDB’s **Aggregation Framework** allows for powerful data transformations and analysis. The **$match**, **$project**, and **$sort** stages are fundamental building blocks of an aggregation pipeline.
44

55
---
66

7-
## **🔹 $match → Filtering Data**
7+
## **🔹 $match → Filtering data**
88

99
Just like `.find()` based on the query mentioned, the `$match` stage filters documents from the collection.
1010

@@ -14,7 +14,7 @@ Just like `.find()` based on the query mentioned, the `$match` stage filters doc
1414
{ $match: { <query> } }
1515
```
1616

17-
### Example: Get All the Books that were published after the year 2010
17+
### Example: Get all the books that were published after the year 2010
1818

1919
```js
2020
db.books.aggregate([
@@ -30,7 +30,7 @@ Place `$match` as early as possible in the pipeline to reduce the number of docu
3030

3131
---
3232

33-
## **🔹 $project → Selecting Fields**
33+
## **🔹 $project → Selecting fields**
3434

3535
- The `$project` stage controls which fields are included in the output.
3636
- It can also be used for adding computed fields to the results.
@@ -50,7 +50,7 @@ Place `$match` as early as possible in the pipeline to reduce the number of docu
5050
- `1`: Include the field
5151
- `0`: Exclude the field
5252

53-
### Example: Get all the books published after the year 2010, the output should only include the title, year and page count of the book.
53+
### Example: Get all the books published after the year 2010. The output should only include the title, year, and page count of the book.
5454

5555
```js
5656
db.books.aggregate([
@@ -68,13 +68,13 @@ db.books.aggregate([
6868
]);
6969
```
7070

71-
### **Equivalent SQL Query**
71+
### **Equivalent SQL query**
7272

7373
```sql
7474
SELECT title, year, pages FROM books WHERE year>2010;
7575
```
7676

77-
### **Computed Fields Example:** Along with the title & authors, also output the count of authors for every book in the database.
77+
### **Computed fields example:** Along with the title and authors, also output the count of authors for every book in the database.
7878

7979
```js
8080
db.books.aggregate([
@@ -105,7 +105,7 @@ db.books.aggregate([
105105
</div>
106106
</details>
107107

108-
### 👐 2. Find books with more than 2 available copies, return only book titles and publication year.
108+
### 👐 2. Find books with more than 2 available copies. Return only book titles and publication year.
109109

110110
<details>
111111
<summary>Answer</summary>

0 commit comments

Comments
 (0)