- Reference >
mongoShell Methods >- Cursor Methods >
- cursor.showRecordId()
cursor.showRecordId()¶
On this page
Definition¶
-
cursor.showRecordId()¶ mongoShell MethodThis page documents the
mongoshell 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.Appends the
$recordIdfield to documents returned by a query.$recordIdis the internal key that uniquely identifies a document in a collection.$recordIdformat:Returns: A modified cursor object that contains the document fields and the appended $recordIdfield.
Example¶
The example uses this pizzas collection:
The following find() example uses
showRecordId() to append the $recordId to the
pizza document fields in the output:
Example output: