Skip to content

Commit 1b32303

Browse files
Pavithra VetriselvanPavithra Vetriselvan
authored andcommitted
DOCS-10020 added comment param documentation to db.col.aggregate() and aggregate
1 parent 467df27 commit 1b32303

File tree

5 files changed

+93
-2
lines changed

5 files changed

+93
-2
lines changed

source/includes/apiargs-dbcommand-aggregate-field.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,19 @@ arg_name: field
139139
interface: dbcommand
140140
operation: aggregate
141141
position: 10
142+
---
143+
name: comment
144+
type: string
145+
optional: true
146+
description: |
147+
148+
Users can specify an arbitrary string to help trace the operation
149+
through the database profiler, currentOp, and logs.
150+
151+
.. versionadded:: 3.6
152+
153+
arg_name: field
154+
interface: dbcommand
155+
operation: aggregate
156+
position: 11
142157
...

source/includes/apiargs-method-db.collection.aggregate-options.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,12 @@ source:
8585
interface: method
8686
operation: db.collection.aggregate
8787
position: 8
88-
88+
---
89+
name: comment
90+
source:
91+
ref: comment
92+
file: apiargs-dbcommand-aggregate-field.yaml
93+
interface: method
94+
operation: db.collection.aggregate
95+
position: 9
8996
...

source/reference/command/aggregate.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ aggregate
3333
bypassDocumentValidation: <boolean>,
3434
readConcern: <document>,
3535
collation: <document>,
36-
hint: <string or document>
36+
hint: <string or document>,
37+
comment: <string>
3738
}
3839

3940
The :dbcommand:`aggregate` command takes the following fields as

source/reference/method/db.collection.aggregate.txt

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,3 +297,61 @@ majority of the nodes.
297297

298298
.. [#agg-index-filters] :ref:`index-filters` can affect the choice of index
299299
used. See :ref:`index-filters` for details.
300+
301+
Specify a Comment
302+
~~~~~~~~~~~~~~~
303+
304+
A collection named ``movies`` contains documents formatted as such:
305+
306+
.. code-block:: javascript
307+
308+
{
309+
"_id" : ObjectId("599b3b54b8ffff5d1cd323d8"),
310+
"title" : "Jaws",
311+
"year" : 1975,
312+
"imdb" : "tt0073195"
313+
}
314+
315+
The following aggregation operation finds movies created in 1995 and includes
316+
the ``comment`` option to provide tracking information in the ``logs``,
317+
the ``db.system.profile`` collection, and ``db.currentOp``.
318+
319+
.. code-block:: javascript
320+
db.movies.aggregate( [ { $match: { year : 1995 } } ], { comment : "match_all_movies_from_1995" } ).pretty()
321+
322+
On a system with profiling enabled, you can then query the ``system.profile``
323+
collection to see all recent similar aggregations, as shown below:
324+
325+
.. code-block:: javascript
326+
327+
db.system.profile.find( { "command.aggregate": "movies", "command.comment" : "match_all_movies_from_1995" } ).sort( { ts : -1 } ).pretty()
328+
329+
This will return a set of profiler results in the following format:
330+
331+
.. code-block:: javascript
332+
333+
{
334+
"op" : "command",
335+
"ns" : "video.movies",
336+
"command" : {
337+
"aggregate" : "movies",
338+
"pipeline" : [
339+
{
340+
"$match" : {
341+
"year" : 1995
342+
}
343+
}
344+
],
345+
"comment" : "match_all_movies_from_1995",
346+
"cursor" : {
347+
348+
},
349+
"$db" : "video"
350+
},
351+
...
352+
}
353+
354+
An application can encode any arbitrary information in the comment in order
355+
to more easily trace or identify specific operations through the system.
356+
For instance, an application might attach a string comment incorporating its
357+
process ID, thread ID, client hostname, and the user who issued the command.

source/release-notes/3.6.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ option to specify the index to use.
6464
The ``hint`` does not apply to :pipeline:`$lookup` and
6565
:pipeline:`$graphLookup` stages.
6666

67+
New ``comment`` Option
68+
~~~~~~~~~~~~~~~~~~~~~~
69+
70+
:dbcommand:`aggregate` command and the
71+
:method:`db.collection.aggregate()` method support a new ``comment``
72+
option to help trace the operation through the database profiler,
73+
currentOp, and logs.
74+
6775
Support for Time Zones
6876
~~~~~~~~~~~~~~~~~~~~~~
6977

@@ -183,6 +191,8 @@ MongoDB 3.6 includes the following enhancements:
183191
- If authentication is turned on, you can only issue a :dbcommand:`getMore`
184192
against cursors you created.
185193

194+
-
195+
186196
Changes Affecting Compatibility
187197
-------------------------------
188198

0 commit comments

Comments
 (0)