@@ -41,8 +41,7 @@ computed results. The MongoDB Aggregation framework is modeled on the
41
41
concept of data processing pipelines. Documents enter a pipeline comprised of one or
42
42
more stages, and this pipeline transforms the documents into an aggregated result.
43
43
44
- To learn more about the aggregation stages supported by the Node.js Driver, see :ref:`Aggregation Stages <>`.
45
- .. todo-- add link here
44
+ To learn more about the aggregation stages supported by the Node.js Driver, see :ref:`Aggregation Stages <node-aggregation-pipeline-stages>`.
46
45
47
46
Analogy
48
47
~~~~~~~
@@ -102,72 +101,12 @@ Consider the following :manual:`limitations </core/aggregation-pipeline-limits/>
102
101
property of the ``AggregateOptions`` object that you pass to the
103
102
``Aggregate()`` method.
104
103
105
- ..
106
- Aggregation Example
107
- -------------------
108
- ..
109
- To perform an aggregation, pass a list of aggregation stages to the
110
- ``collection.aggregate()`` method.
111
- ..
112
- .. note::
113
- ..
114
- This example uses the ``sample_restaurants.restaurants`` collection
115
- from the :atlas:`Atlas sample datasets </sample-data>`. To learn how to create a
116
- free MongoDB Atlas cluster and load the sample datasets, see the :ref:`Get Started <node-get-started>` guide.
117
- ..
118
- The following code example produces a count of the number of bakeries in each borough
119
- of New York City. To do so, the aggregation pipeline uses the following aggregation stages:
120
- ..
121
- - A :manual:`$match </reference/operator/aggregation/match/>` stage to filter
122
- for documents whose ``cuisine`` field contains the element ``Bakery``.
123
- ..
124
- - A :manual:`$group </reference/operator/aggregation/group/>` stage to group the
125
- matching documents by the ``borough`` field, accumulating a count of documents
126
- for each distinct value in the ``borough`` field.
127
- ..
128
- .. literalinclude:: /code-snippets/aggregation/agg.js
129
- :start-after: begin aggregation
130
- :end-before: end aggregation
131
- :language: javascript
132
- :dedent:
133
- ..
134
- This example produces the following output:
135
- ..
136
- .. code-block:: json
137
- :copyable: false
138
- ..
139
- { _id = 'Bronx', count = 71 }
140
- { _id = 'Brooklyn', count = 173 }
141
- { _id = 'Staten Island', count = 20 }
142
- { _id = 'Missing', count = 2 }
143
- { _id = 'Manhattan', count = 221 }
144
- { _id = 'Queens', count = 204 }
145
-
146
104
Additional information
147
105
----------------------
148
106
149
107
To view a full list of expression operators, see
150
108
:manual:`Aggregation Operators </reference/operator/aggregation/>`.
151
109
152
- ..
153
- To learn more about assembling an aggregation pipeline and view examples, see
154
- :manual:`Aggregation Pipeline </core/aggregation-pipeline/>`.
155
- ..
156
- To learn more about creating pipeline stages and view examples, see
157
- :manual:`Aggregation Stages </reference/operator/aggregation-pipeline/>`.
158
-
159
110
To learn about explaining MongoDB aggregation operations, see
160
111
:manual:`Explain Results </reference/explain-results/>` and
161
112
:manual:`Query Plans </core/query-plans/>`.
162
-
163
- ..
164
- API Documentation
165
- ~~~~~~~~~~~~~~~~~
166
- ..
167
- For more information about the aggregation operations discussed in this guide, see the
168
- following API documentation:
169
- ..
170
- - `Collection() <https://mongodb.github.io/node-mongodb-native/6.17/classes/Collection.html>`__
171
- - `aggregate() <https://mongodb.github.io/node-mongodb-native/6.17/classes/Collection.html#aggregate>`__
172
- - `AggregateOptions <https://mongodb.github.io/node-mongodb-native/6.17/interfaces/AggregateOptions.html>`__
173
- .. try to find $match and $group api links ..
0 commit comments