Skip to content

Update 6-writing-long-pipelines.mdx #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/30-simple-queries/6-writing-long-pipelines.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import TabItem from '@theme/TabItem';
Extra activity! Do it if you have extra time or are following along at home. It won't be covered during the hands-on lab.
:::

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

:::danger
The following syntax doesn't work in the Atlas UI aggregations editor. The editor doesn't support declaring variables. You can try this using the built-in MongoDB Shell in [MongoDB Compass](https://www.mongodb.com/products/tools/compass).
Expand All @@ -28,7 +28,7 @@ db.books.aggregate([
{ $limit: 15 }
])
```
Will be changed into:
This will be changed into:


```js
Expand Down Expand Up @@ -58,12 +58,12 @@ Write your aggregation pipelines like you'll compose functions in your programmi

:::tip

As this is code, we can even add comments (starting with `//`) to our pipelines. Or write functions that take parameters and return a stage. Or unit test our stages.
As this is code, we can even add comments (starting with `//`) to our pipelines, or write functions that take parameters and return a stage, or unit test our stages.

:::


👐 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)).
👐 We can also use `$gte` to get the books with 150 pages or more. Check $gte syntax in the [documentation](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)).

<details>
<summary>Answer</summary>
Expand Down