You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/30-simple-queries/2-match.mdx
+71-39
Original file line number
Diff line number
Diff line change
@@ -3,15 +3,15 @@ import TabItem from '@theme/TabItem';
3
3
4
4
# 👐 $match
5
5
6
-
The $matchoperator is used in conjunction with the aggregation framework to filter documents in a collection. It takes a document as input and returns a new document containing only the documents that match the specified criteria. The syntax for the $match operator is as follows:
6
+
The [$match](https://www.mongodb.com/docs/manual/reference/operator/aggregation/match/) stage filters documents in a collection. It takes a document as input (your filter) and returns the documents that match the specified criteria. The syntax for the $match stage is as follows:
7
7
8
8
```js
9
9
{ $match: { <expression>:<value> } }
10
10
```
11
11
12
12
## Expressions
13
13
14
-
The `<expression>` portion of the $match operator can be any valid MongoDB expression. This includes:
14
+
The `<expression>` portion of the $match stage can be any valid MongoDB expression. This includes:
If we need to add more conditions using AND, we can do it with the `$and` operator.
93
+
If we need to add more conditions using AND, we use the `$and` operator.
86
94
87
-
If we want all the books with 100 pages with exactly `totalInventory`2, we can use a`$and` operator. This takes an array of documents with all the conditions that should be true for the AND to succeed:
95
+
If we want all the books with 100 pages and with exactly `totalInventory`1, we can use the`$and` operator. It takes an array of documents with all the conditions that should be true for the AND to succeed:
- 1 means "show that field.". Once you started an inclusion projection you can't exclude other fields (you just keep adding the fields you want to see)
89
+
- 0 means "hide that field.". Once you started an exclusion projection you can't include other fields (you just keep adding the fields you don't want to see)
86
90
- The primary key `_id` field is shown by default.
87
91
88
92
So we can exclude fields and show all fields except `attributes` using:
@@ -92,14 +96,18 @@ So we can exclude fields and show all fields except `attributes` using:
0 commit comments