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