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/1-mongodb-atlas/15-prerequisites.mdx
+2-2
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,6 @@ description: Setting up your MongoDB Atlas account, importing Library data
6
6
7
7
To follow along you'll need:
8
8
- a MongoDB Atlas account
9
-
-some test data, in this case this is Books, Authors and Reviews data for a Library management system.
9
+
- test data. In this case, this is books, authors and reviews data for a library management system.
10
10
11
-
💻 To get both, open the [Intro Lab](https://mongodb-developer.github.io/intro-lab/docs/intro) and follow it (only takes 10-15 mins) to get your database ready. Return here when finished!
11
+
💻 To get both, open the [Intro Lab](https://mongodb-developer.github.io/intro-lab/docs/intro) and follow it (only takes 10-15 mins) to get your database ready. Return here when finished!
Copy file name to clipboardExpand all lines: docs/30-simple-queries/1-empty-aggregation.mdx
+15-14
Original file line number
Diff line number
Diff line change
@@ -8,31 +8,28 @@ import TabItem from '@theme/TabItem';
8
8
This code is the equivalent to a `SELECT * FROM AUTHORS`. Returns a [cursor](https://www.mongodb.com/docs/manual/reference/method/js-cursor/) with all documents in the `authors` collection:
9
9
10
10
<TabsgroupId="aggregations">
11
-
<TabItemvalue="mongosh"label="mongosh">
12
11
13
-
```js
14
-
db.authors.aggregate([])
15
-
```
12
+
<TabItemvalue="atlas"label="Atlas UI">
16
13
17
-
</TabItem>
18
-
<TabItemvalue="atlas"label="Atlas UI">
14
+
<Screenshotsrc="/img/30-simple-queries/atlas-aggregation.png"url="http://cloud.mongodb.com/"alt="Atlas UI showing an empty aggregation pipeline" />
19
15
20
-
<Screenshotsrc="/img/30-simple-queries/atlas-aggregation.png"url="http://cloud.mongodb.com/yourcluster"alt="AtlasUI Showing the available DBs" />
21
-
22
-
- Open the Aggregation tab
23
-
- Select Text entry
24
-
- Type in the aggregation pipeline:
16
+
- Open the `Aggregation` tab.
17
+
- Select `Text`.
18
+
- Notice the empty array in the editor denoting an empty aggregation pipeline:
Copy file name to clipboardExpand all lines: docs/30-simple-queries/2-match.mdx
+154-6
Original file line number
Diff line number
Diff line change
@@ -1,34 +1,115 @@
1
-
# $match
1
+
importTabsfrom'@theme/Tabs';
2
+
importTabItemfrom'@theme/TabItem';
2
3
3
-
This is the simplest one, similar to the `WHERE` SQL clause.
4
+
# $match
4
5
5
-
Say we want all the books from 2010. We'll write:
6
+
The $match operator 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
7
7
8
```js
8
-
db.books.aggregate([{$match: {year:2010}}])
9
+
{ $match: {<expression>:<value> } }
9
10
```
10
11
12
+
## Expressions
13
+
14
+
The `<expression>` portion of the $match operator can be any valid MongoDB expression. This includes :
First, make sure you select the `books` collection in the Atlas UI.
27
+
<Screenshotsrc="/img/30-simple-queries/select-books-collection.png"url="http://cloud.mongodb.com/"alt="Atlas UI database deployment with the books collection highlighted." />
28
+
29
+
Then, navigate to the `Aggregation` tab and click `Add Stage`.
30
+
<Screenshotsrc="/img/30-simple-queries/new-aggregation.png"url="http://cloud.mongodb.com/"alt="Atlas UI database deployment with aggregation tab highlighted." />
31
+
32
+
Say we want all the books from the year 2010. We can add a `$match` stage to filter the documents from the books collection:
33
+
34
+
```js
35
+
[
36
+
{
37
+
$match: { year:2010 }
38
+
}
39
+
]
40
+
```
41
+
42
+
<Screenshotsrc="/img/30-simple-queries/match-screenshot.png"url="http://cloud.mongodb.com/"alt="Atlas AI $match aggregation." />
If we need to add more conditions using AND, we can do it using the `$and` operator.
85
+
If we need to add more conditions using AND, we can do it with the `$and` operator.
26
86
27
87
If we want all the books with 100 pages with exactly `totalInventory` 2 we can use an `$and` operator. This takes and array of documents with all the conditions that should be true for the AND to succeed:
0 commit comments