- Reference >
mongo
Shell Methods >- Cursor Methods >
- cursor.showRecordId()
cursor.showRecordId()¶
On this page
-
cursor.
showRecordId
()¶ mongo
Shell MethodThis page documents the
mongo
shell method, and does not refer to the MongoDB Node.js driver (or any other driver) method. For corresponding MongoDB driver API, refer to your specific MongoDB driver documentation instead.Changed in version 3.2: This method replaces the previous
cursor.showDiskLoc()
.Modifies the output of a query by adding a field
$recordId
to matching documents.$recordId
is the internal key which uniquely identifies a document in a collection. It has the form:Returns: A modified cursor object that contains documents with appended information describing the internal record key.
Example¶
The following operation appends the showRecordId()
method to the db.collection.find()
method in order to include
storage engine record information in the matching documents:
The operation returns the following documents, which include the $recordId
field:
You can project the added field $recordId
, as in the
following example:
This query returns only the _id
field and the $recordId
field in the matching documents: