From a6f5bde3d1144bc399e291dc8e8e1934cbda9f3a Mon Sep 17 00:00:00 2001 From: Meg528 <71841959+Meg528@users.noreply.github.com> Date: Tue, 11 Feb 2025 11:12:35 -0700 Subject: [PATCH] Update 2-match-project.mdx --- docs/50-aggregation/2-match-project.mdx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/50-aggregation/2-match-project.mdx b/docs/50-aggregation/2-match-project.mdx index a17265b..a5568c8 100644 --- a/docs/50-aggregation/2-match-project.mdx +++ b/docs/50-aggregation/2-match-project.mdx @@ -1,10 +1,10 @@ # ๐Ÿ‘ $match and $project -MongoDBโ€™s **Aggregation Framework** allows for powerful data transformations and analysis. The **$match**, **$project** & **$sort** stages are fundamental building blocks of an aggregation pipeline. +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. --- -## **๐Ÿ”น $match โ†’ Filtering Data** +## **๐Ÿ”น $match โ†’ Filtering data** Just like `.find()` based on the query mentioned, the `$match` stage filters documents from the collection. @@ -14,7 +14,7 @@ Just like `.find()` based on the query mentioned, the `$match` stage filters doc { $match: { } } ``` -### Example: Get All the Books that were published after the year 2010 +### Example: Get all the books that were published after the year 2010 ```js db.books.aggregate([ @@ -30,7 +30,7 @@ Place `$match` as early as possible in the pipeline to reduce the number of docu --- -## **๐Ÿ”น $project โ†’ Selecting Fields** +## **๐Ÿ”น $project โ†’ Selecting fields** - The `$project` stage controls which fields are included in the output. - 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 - `1`: Include the field - `0`: Exclude the field -### Example: Get all the books published after the year 2010, the output should only include the title, year and page count of the book. +### Example: Get all the books published after the year 2010. The output should only include the title, year, and page count of the book. ```js db.books.aggregate([ @@ -68,13 +68,13 @@ db.books.aggregate([ ]); ``` -### **Equivalent SQL Query** +### **Equivalent SQL query** ```sql SELECT title, year, pages FROM books WHERE year>2010; ``` -### **Computed Fields Example:** Along with the title & authors, also output the count of authors for every book in the database. +### **Computed fields example:** Along with the title and authors, also output the count of authors for every book in the database. ```js db.books.aggregate([ @@ -105,7 +105,7 @@ db.books.aggregate([ -### ๐Ÿ‘ 2. Find books with more than 2 available copies, return only book titles and publication year. +### ๐Ÿ‘ 2. Find books with more than 2 available copies. Return only book titles and publication year.
Answer