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/6-writing-long-pipelines.mdx
+9-9Lines changed: 9 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,14 @@
1
-
# 👐 Writing long pipelines
1
+
# 👐 Writing Long Pipelines
2
2
3
-
Aggregation pipelines can get very long, depending on how many stages we need to run. Writing a pipeline is writing code, as you will write it using one of the many MongoDB drivers in your own language. Here we're presenting the examples using JavaScript suitable for the MongoDB Shell[mongosh](https://www.mongodb.com/docs/mongodb-shell/), but if you are writing a microservice in Rust, you'll definitely write your pipelines in Rust.
3
+
Aggregation pipelines can get very long, depending on how many stages we need to run. Writing a pipeline is writing code, as you will write it using one of the many MongoDB drivers in your own language. Here we're presenting the examples using JavaScript suitable for the MongoDB shell[mongosh](https://www.mongodb.com/docs/mongodb-shell/), but if you are writing a microservice in Rust, you'll definitely write your pipelines in Rust.
4
4
5
5
:::danger
6
6
The following syntax doesn't work in the Atlas UI aggregations editor. The editor doesn't support declaring variables.
7
7
:::
8
8
9
9
This is why we should rewrite our last pipeline like this:
10
10
11
-
Get 15 books from 1985 with 150 pages. Show only the `title`, `year`, `totalInventory` and `available` books. (Sample doc [here](/docs/simple-queries/project))
11
+
Get 15 books from 1985 with 150 pages. Show only the `title`, `year`, `totalInventory`, and `available` books (sample doc [here](/docs/simple-queries/project)).
12
12
13
13
```js
14
14
db.books.aggregate([
@@ -30,26 +30,26 @@ db.books.aggregate([
30
30
]);
31
31
```
32
32
33
-
Easier to read, and reason about, right?
33
+
Easier to read and understand, right?
34
34
35
-
👐 Try to run the above pipeline and compare your results: should be the same as before
35
+
👐 Try to run the above pipeline and compare your results. They should be the same as before.
36
36
37
37
:::tip
38
38
39
-
Write your aggregation pipelines like you'll compose functions in your programming language. Aggregations _are_ code that runs on the server. In the client you just express _what_ you want to be done, not _how_ to do it.
39
+
Write your aggregation pipelines like you'll compose functions in your programming language. Aggregations _are_ code that runs on the server. In the client, you just express _what_ you want to be done, not _how_ to do it.
40
40
41
41
:::
42
42
43
43
:::tip
44
44
45
-
As this is code, we can even add comments (starting with `//`) to our pipelines
45
+
As this is code, we can even add comments (starting with `//`) to our pipelines.
46
46
47
47
:::
48
48
49
49
50
-
👐 We can also use $gte to get the books with 150 pages or more. Check $gte syntax in the [docucumentation](https://www.mongodb.com/docs/manual/reference/operator/query/gte/) and write an aggregation pipeline to return 15 books from 1985 with more than 150 pages. Show only the `title`, `year`, `totalInventory` and `available` books. (Sample doc [here](/docs/simple-queries/project))
50
+
👐 We can also use $gte to get the books with 150 pages or more. Check $gte syntax in the [docucumentation](https://www.mongodb.com/docs/manual/reference/operator/query/gte/) and write an aggregation pipeline to return 15 books from 1985 with more than 150 pages. Show only the `title`, `year`, `totalInventory`, and `available` books (sample doc [here](/docs/simple-queries/project)).
51
51
52
-
_Hint:_we'll need to use `$and` as maybe this is a bit more complex.
52
+
_Hint:_We'll need to use `$and` as maybe this is a bit more complex.
0 commit comments