Skip to content

Commit 8b38596

Browse files
authored
Merge pull request #20 from Meg528/patch-12
Update 6-writing-long-pipelines.mdx
2 parents 0c2bb74 + 123130a commit 8b38596

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

docs/30-simple-queries/6-writing-long-pipelines.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# 👐 Writing long pipelines
1+
# 👐 Writing Long Pipelines
22

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.
44

55
:::danger
66
The following syntax doesn't work in the Atlas UI aggregations editor. The editor doesn't support declaring variables.
77
:::
88

99
This is why we should rewrite our last pipeline like this:
1010

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)).
1212

1313
```js
1414
db.books.aggregate([
@@ -30,26 +30,26 @@ db.books.aggregate([
3030
]);
3131
```
3232

33-
Easier to read, and reason about, right?
33+
Easier to read and understand, right?
3434

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.
3636

3737
:::tip
3838

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.
4040

4141
:::
4242

4343
:::tip
4444

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.
4646

4747
:::
4848

4949

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)).
5151

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.
5353

5454
<details>
5555
<summary>Answer</summary>

0 commit comments

Comments
 (0)