Skip to content

Commit 4bf39fe

Browse files
jason-price-mongodbjason-price-mongodb
andauthored
DOCS-15547 show record id (#1692) (#1703)
* DOCS-15547-show-record-id * DOCS-15547-show-record-id * DOCS-15547-show-record-id * DOCS-15547-show-record-id * DOCS-15547-show-record-id * DOCS-15547-show-record-id * DOCS-15547-show-record-id * DOCS-15547-show-record-id * DOCS-15547-show-record-id Co-authored-by: jason-price-mongodb <[email protected]> Co-authored-by: jason-price-mongodb <[email protected]>
1 parent 989a7f2 commit 4bf39fe

File tree

2 files changed

+46
-47
lines changed

2 files changed

+46
-47
lines changed
Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
The following operation appends the :method:`~cursor.showRecordId()`
2-
method to the :method:`db.collection.find()` method in order to include
3-
storage engine record information in the matching documents:
1+
The example uses this ``pizzas`` collection:
42

53
.. code-block:: javascript
64
7-
db.collection.find( { a: 1 } ).showRecordId()
5+
db.pizzas.insertMany( [
6+
{ type: "pepperoni", size: "small", price: 4 },
7+
{ type: "cheese", size: "medium", price: 7 },
8+
{ type: "vegan", size: "large", price: 8 }
9+
] )
810
9-
The operation returns the following documents, which include the ``$recordId``
10-
field:
11+
The following :method:`~db.collection.find()` example uses
12+
:method:`~cursor.showRecordId()` to append the ``$recordId`` to the
13+
``pizza`` document fields in the output:
1114

1215
.. code-block:: javascript
1316
14-
{
15-
"_id" : ObjectId("53908ccb18facd50a75bfbac"),
16-
"a" : 1,
17-
"b" : 1,
18-
"$recordId" : NumberLong(168112)
19-
}
20-
{
21-
"_id" : ObjectId("53908cd518facd50a75bfbad"),
22-
"a" : 1,
23-
"b" : 2,
24-
"$recordId" : NumberLong(168176)
25-
}
26-
27-
You can :term:`project <projection>` the added field ``$recordId``, as in the
28-
following example:
17+
db.pizzas.find().showRecordId()
2918
30-
.. code-block:: javascript
31-
32-
db.collection.find( { a: 1 }, { $recordId: 1 } ).showRecordId()
33-
34-
This query returns only the ``_id`` field and the ``$recordId``
35-
field in the matching documents:
19+
Example output:
3620

3721
.. code-block:: javascript
38-
39-
{
40-
"_id" : ObjectId("53908ccb18facd50a75bfbac"),
41-
"$recordId" : NumberLong(168112)
42-
}
43-
{
44-
"_id" : ObjectId("53908cd518facd50a75bfbad"),
45-
"$recordId" : NumberLong(168176)
46-
}
22+
:copyable: false
23+
24+
[
25+
{
26+
_id: ObjectId("62ffc70660b33b68e8f30435"),
27+
type: 'pepperoni',
28+
size: 'small',
29+
price: 4,
30+
'$recordId': Long("1")
31+
},
32+
{
33+
_id: ObjectId("62ffc70660b33b68e8f30436"),
34+
type: 'cheese',
35+
size: 'medium',
36+
price: 7,
37+
'$recordId': Long("2")
38+
},
39+
{
40+
_id: ObjectId("62ffc70660b33b68e8f30437"),
41+
type: 'vegan',
42+
size: 'large',
43+
price: 8,
44+
'$recordId': Long("3")
45+
}
46+
]

source/reference/method/cursor.showRecordId.txt

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,24 @@ cursor.showRecordId()
1010
:depth: 1
1111
:class: singlecol
1212

13-
.. method:: cursor.showRecordId()
13+
Definition
14+
----------
1415

16+
.. method:: cursor.showRecordId()
1517

1618
.. include:: /includes/fact-mongo-shell-method.rst
1719

18-
19-
.. versionchanged:: 3.2
20-
This method replaces the previous ``cursor.showDiskLoc()``.
21-
22-
Modifies the output of a query by adding a field ``$recordId`` to
23-
matching documents. ``$recordId`` is the internal key which uniquely
24-
identifies a document in a collection. It has the form:
20+
Appends the ``$recordId`` field to documents returned by a query.
21+
``$recordId`` is the internal key that uniquely identifies a document
22+
in a collection. ``$recordId`` format:
2523

2624
.. code-block:: javascript
25+
:copyable: false
2726

28-
"$recordId": NumberLong(<int>)
27+
'$recordId': Long(<int>)
2928

30-
:returns: A modified cursor object that contains documents with
31-
appended information describing the internal record key.
29+
:returns: A modified cursor object that contains the document fields
30+
and the appended ``$recordId`` field.
3231

3332
Example
3433
-------

0 commit comments

Comments
 (0)