@@ -15,14 +15,6 @@ Aggregation
1515 :depth: 2
1616 :class: singlecol
1717
18- .. toctree::
19-
20- Filtered Subset </aggregation/filtered-subset/>
21- Group & Total </aggregation/group-total/>
22- Unpack Arrays & Group </aggregation/unpack-arrays/>
23- One-to-One Join </aggregation/one-to-one-join/>
24- Multi-Field Join </aggregation/multi-field-join/>
25-
2618.. _nodejs-aggregation-overview:
2719
2820Overview
@@ -36,6 +28,14 @@ and summarized results in MongoDB. MongoDB's aggregation framework
3628allows you to create a pipeline that consists of one or more stages,
3729each of which performs a specific operation on your data.
3830
31+ .. _node-aggregation-tutorials:
32+
33+ .. sharedinclude:: dbx/agg-tutorials-manual-tip.rst
34+
35+ .. replacement:: language
36+
37+ :guilabel:`{+environment+}`
38+
3939Analogy
4040~~~~~~~
4141
@@ -143,112 +143,9 @@ This example produces the following output:
143143
144144For more information, see the `aggregate() API documentation <{+api+}/classes/Collection.html#aggregate>`__.
145145
146- .. _node-aggregation-tutorials-landing:
147- .. _node-aggregation-tutorials:
148-
149- Aggregation Tutorials
150- ---------------------
151-
152- Aggregation tutorials provide detailed explanations of common
153- aggregation tasks in a step-by-step format. The tutorials are adapted
154- from examples in the `Practical MongoDB Aggregations book
155- <https://www.practical-mongodb-aggregations.com/>`__ by Paul Done.
156-
157- Each tutorial includes the following sections:
158-
159- - **Introduction**, which describes the purpose and common use cases of the
160- aggregation type. This section also describes the example and desired
161- outcome that the tutorial demonstrates.
162-
163- - **Before You Get Started**, which describes the necessary databases,
164- collections, and sample data that you must have before building the
165- aggregation pipeline and performing the aggregation.
166-
167- - **Tutorial**, which describes how to build and run the aggregation
168- pipeline. This section describes each stage of the completed
169- aggregation tutorial, and then explains how to run and interpret the
170- output of the aggregation.
171-
172- At the end of each aggregation tutorial, you can find a link to a fully
173- runnable Node.js code file that you can run in your environment.
174-
175- .. tip::
176-
177- To learn more about performing aggregations, see the
178- :ref:`node-aggregation` guide.
179-
180- .. _node-agg-tutorial-template-app:
181-
182- Aggregation Template App
183- ~~~~~~~~~~~~~~~~~~~~~~~~
184-
185- Before you begin following an aggregation tutorial, you must set up a
186- new Node.js app. You can use this app to connect to a MongoDB
187- deployment, insert sample data into MongoDB, and run the aggregation
188- pipeline in each tutorial.
189-
190- .. tip::
191-
192- To learn how to install the driver and connect to MongoDB,
193- see the :ref:`node-get-started-download-and-install` and
194- :ref:`node-get-started-create-deployment` steps of the
195- Quick Start guide.
196-
197- Once you install the driver, create a file called
198- ``agg_tutorial.js``. Paste the following code in this file to create an
199- app template for the aggregation tutorials:
200-
201- .. literalinclude:: /includes/aggregation/template-app.js
202- :language: javascript
203- :copyable: true
204-
205- .. important::
206-
207- In the preceding code, read the code comments to find the sections of
208- the code that you must modify for the tutorial you are following.
209-
210- If you attempt to run the code without making any changes, you will
211- encounter a connection error.
212-
213- For every tutorial, you must replace the connection string placeholder with
214- your deployment's connection string.
215-
216- .. tip::
217-
218- To learn how to locate your deployment's connection string, see the
219- :ref:`node-get-started-connection-string` step of the Quick Start guide.
220-
221- For example, if your connection string is
222- ``"mongodb+srv://mongodb-example:27017"``, your connection string assignment resembles
223- the following:
224-
225- .. code-block:: javascript
226- :copyable: false
227-
228- const uri = "mongodb+srv://mongodb-example:27017";
229-
230- To run the completed file after you modify the template for a
231- tutorial, run the following command in your shell:
232-
233- .. code-block:: bash
234-
235- node agg_tutorial.js
236-
237- Available Tutorials
238- ~~~~~~~~~~~~~~~~~~~
239-
240- - :ref:`node-aggregation-filtered-subset`
241- - :ref:`node-aggregation-group-total`
242- - :ref:`node-aggregation-arrays`
243- - :ref:`node-aggregation-one-to-one`
244- - :ref:`node-aggregation-multi-field`
245-
246146Additional Examples
247147~~~~~~~~~~~~~~~~~~~
248148
249- To view step-by-step explanations of common aggregation tasks, see the
250- :ref:`node-aggregation-tutorials-landing`.
251-
252149You can find another aggregation pipeline example in the `Aggregation
253150Framework with Node.js Tutorial
254151<https://www.mongodb.com/blog/post/quick-start-nodejs--mongodb--how-to-analyze-data-using-the-aggregation-framework>`_
0 commit comments