Skip to content

Commit 11139ae

Browse files
committed
tweak examples for cpp
1 parent 61bb195 commit 11139ae

File tree

5 files changed

+34
-16
lines changed

5 files changed

+34
-16
lines changed
Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
collection: "inventory"
1+
collection: "restaurants"
22
options:
33
base_file: true
44
---
@@ -7,11 +7,11 @@ title:
77
level: 2
88
ref: _group-documents-by-a-field-and-calculate-count
99
pre: |
10-
Use the :pipeline:`$group` stage to group by a specified key. In the
11-
:pipeline:`$group` stage, specify the group by key in the ``_id``
12-
field. :pipeline:`$group` accesses fields by the field path, which is
10+
Use the {{stageGroup}} stage to group by a specified key. In the
11+
{{stageGroup}} stage, specify the group by key in the ``_id``
12+
field. {{stageGroup}} accesses fields by the field path, which is
1313
the field name prefixed by a dollar sign ``$``. The
14-
:pipeline:`$group` stage can use :manual:`accumulators
14+
{{stageGroup}} stage can use :manual:`accumulators
1515
</meta/aggregation-quick-reference/#group-operators>` to perform
1616
calculations for each group.
1717
@@ -23,29 +23,33 @@ post: |
2323
final: |
2424
The ``_id`` field contains the distinct ``borough`` value, i.e., the
2525
group by key value.
26+
replacement:
27+
stageGroup: ":pipeline:`$group`"
2628
---
2729
title:
2830
text: Filter and Group Documents
2931
level: 2
3032
ref: _filter-and-group-documents
3133
pre: |
32-
Use the :pipeline:`$match` stage to filter documents.
33-
:pipeline:`$match` uses the MongoDB :doc:`query syntax
34+
Use the {{stageMatch}} stage to filter documents.
35+
{{stageMatch}} uses the MongoDB :doc:`query syntax
3436
</query>`.
3537
36-
The following pipeline uses :pipeline:`$match` to query the
38+
The following pipeline uses {{stageMatch}} to query the
3739
``restaurants`` collection for documents with ``borough`` equal to
3840
``"Queens"`` and ``cuisine`` equal to ``Brazilian``.
3941
40-
Then the :pipeline:`$group` stage groups the matching documents
42+
Then the {{stageGroup}} stage groups the matching documents
4143
by the ``address.zipcode`` field and uses the :group:`$sum`
42-
accumulator to calculate the count. :pipeline:`$group` accesses
44+
accumulator to calculate the count. {{stageGroup}} accesses
4345
fields by the field path, which is the field name prefixed by a
4446
dollar sign ``$``.
4547
post: |
4648
The result set consists of the following documents:
4749
final: |
4850
The ``_id`` field contains the distinct ``zipcode`` value, i.e., the
4951
group by key value.
50-
52+
replacement:
53+
stageGroup: ":pipeline:`$group`"
54+
stageMatch: ":pipeline:`$match`"
5155
...

primer/source/includes/examples-aggregation.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ edition: cpp
188188
operation:
189189
literalinclude: includes/example-cpp-group-documents-by-a-field-and-calculate-count.cpp
190190
language: cpp
191+
post: ''
192+
final: ''
193+
replacement:
194+
stageGroup: "`group <http://mongodb.github.io/mongo-cxx-driver/classmongocxx_1_1pipeline.html#ade56123c1bb038002fb648dce506da08>`_"
191195
---
192196
source:
193197
file: examples-aggregation-base.yaml
@@ -197,6 +201,12 @@ edition: cpp
197201
operation:
198202
literalinclude: includes/example-cpp-filter-and-group-documents.cpp
199203
language: cpp
204+
post: ''
205+
final: ''
206+
replacement:
207+
stageGroup: "`group <http://mongodb.github.io/mongo-cxx-driver/classmongocxx_1_1pipeline.html#ade56123c1bb038002fb648dce506da08>`_"
208+
stageMatch: "`match <http://mongodb.github.io/mongo-cxx-driver/classmongocxx_1_1pipeline.html#af60dba76fccb47386c0a3e6755635ed4>`_"
209+
200210
---
201211
source:
202212
file: examples-aggregation-base.yaml

primer/source/includes/extracts-aggregation-overview.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,13 @@ content: |
5151
5252
You can use the {{aggregate}} method to
5353
perform a stage-based aggregation. The
54-
{{aggregate}} method accepts as its argument a pipeline
54+
{{aggregate}} method accepts as its argument a pipeline_
5555
of stages, where each :manual:`stage
5656
</meta/aggregation-quick-reference>`, processed sequentially, describes
5757
a data processing step.
5858
5959
.. _aggregate: http://mongodb.github.io/mongo-cxx-driver/classmongocxx_1_1collection.html#aa93a46c9e07878fbddeb3ca29af71fc4
60+
.. _pipeline: http://mongodb.github.io/mongo-cxx-driver/classmongocxx_1_1pipeline.html
6061
replacement:
6162
aggregate: "aggregate_"
6263
---

primer/source/includes/extracts-connect.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ content: |
66
``test`` database.
77
88
.. code-block:: cpp
9-
9+
10+
mongocxx::instance inst{};
1011
mongocxx::client conn{};
1112
1213
auto db = conn["test"];
14+
1315
---
1416
ref: java-connect
1517
edition: java

primer/source/includes/steps-client-install-cpp.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ edition: cpp
33
ref: download-cpp
44
content: |
55
Download the source from
6-
`<https://github.com/mongodb/mongo-cxx-driver/releases>`_.
6+
`<https://github.com/mongodb/mongo-cxx-driver>`_.
77
---
88
title: "Compile the Driver"
99
edition: cpp
1010
ref: compile-cpp
1111
content: |
1212
To compile, follow the build instructions on
13-
`<https://github.com/mongodb/mongo-cxx-driver/wiki/Download-and-Compile-the-Legacy-Driver>`_.
13+
`<https://github.com/mongodb/mongo-cxx-driver/wiki/Quickstart-Guide-(New-Driver)>`_.
1414
---
1515
title: "Connect to MongoDB"
1616
edition: cpp
@@ -22,10 +22,11 @@ pre: |
2222
Add the following code in your C++ program.
2323
action:
2424
- pre: |
25-
Add the following ``#include`` statement.
25+
Add the following ``#include`` statements.
2626
language: javascript
2727
code: |
2828
#include <mongocxx/client.hpp>
29+
#include <mongocxx/instance.hpp>
2930
3031
- content: |
3132
.. include:: includes/extracts/cpp-connect.rst

0 commit comments

Comments
 (0)