[DOCS-15547] Fix example in documentation of 'showRecordId()' cursor method Created: 18/Aug/22  Updated: 13/Nov/23  Resolved: 23/Aug/22

Status: Closed
Project: Documentation
Component/s: manual, Server
Affects Version/s: None
Fix Version/s: 4.2.0, 4.4.0, 5.0.0, 6.0.0, Server_Docs_20231030, Server_Docs_20231106, Server_Docs_20231105, Server_Docs_20231113

Type: Bug Priority: Major - P3
Reporter: David Storch Assignee: Jason Price
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-67539 Discrepancy in `showRecordId()` behavior Closed
Participants:
Days since reply: 1 year, 22 weeks, 1 day ago
Epic Link: DOCSP-11701
Story Points: 3

 Description   

While investigating SERVER-67539, we noticed that the documentation for showRecordId() has a stale example. There is more context in SERVER-67539 but I will explain the problem here as well. This pertains to the following docs page: https://www.mongodb.com/docs/manual/reference/method/cursor.showRecordId/.

At the bottom of the page, we have the following example:

You can project the added field $recordId, as in the following example:

db.collection.find( { a: 1 }, { $recordId: 1 } ).showRecordId()

This query returns only the _id field and the $recordId field in the matching documents:

{
"_id" : ObjectId("53908ccb18facd50a75bfbac"),
"$recordId" : NumberLong(168112)
}
{
"_id" : ObjectId("53908cd518facd50a75bfbad"),
"$recordId" : NumberLong(168176)
}

This used to be accurate, but the behavior changed in MongoDB 4.4 as part of PM-684. The server will now omit the "$recordId" field for this query:

MongoDB Enterprise > db.c.find({}, {$recordId: 1}).showRecordId()
{ "_id" : ObjectId("62fead4bee4c4666b602252e") }
{ "_id" : ObjectId("62fead4bee4c4666b6022530") }
{ "_id" : ObjectId("62fead4cee4c4666b6022532") }

We should either correct the example or delete it. The following query can be used instead against 4.4+ versions of the server to return results containing just the _id and $recordId fields:

MongoDB Enterprise > db.c.find({}, {_id: 1}).showRecordId()
{ "_id" : ObjectId("62fead4bee4c4666b602252e"), "$recordId" : NumberLong(1) }
{ "_id" : ObjectId("62fead4bee4c4666b6022530"), "$recordId" : NumberLong(2) }
{ "_id" : ObjectId("62fead4cee4c4666b6022532"), "$recordId" : NumberLong(3) }



 Comments   
Comment by Githook User [ 06/Sep/22 ]

Author:

{'name': 'jason-price-mongodb', 'email': '69260375+jason-price-mongodb@users.noreply.github.com', 'username': 'jason-price-mongodb'}

Message: DOCS-15547 show record id (#1692)

Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com>
Branch: v6.1
https://github.com/10gen/docs-mongodb-internal/commit/9d0ccdf88cd1f10f6862b2e57cbee728edc369be

Comment by Githook User [ 23/Aug/22 ]

Author:

{'name': 'jason-price-mongodb', 'email': '69260375+jason-price-mongodb@users.noreply.github.com', 'username': 'jason-price-mongodb'}

Message: DOCS-15547 show record id (#1692) (#1703)

Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com>

Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com>
Branch: v4.2
https://github.com/10gen/docs-mongodb-internal/commit/4bf39fe6aba82a2b2f07b9ac17d83a5c7d57e37d

Comment by Githook User [ 23/Aug/22 ]

Author:

{'name': 'jason-price-mongodb', 'email': '69260375+jason-price-mongodb@users.noreply.github.com', 'username': 'jason-price-mongodb'}

Message: DOCS-15547 show record id (#1692) (#1701)

Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com>

Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com>
Branch: v4.4
https://github.com/10gen/docs-mongodb-internal/commit/84bfd8f86460fa54d334a5dc4b63c499e8dfa851

Comment by Githook User [ 23/Aug/22 ]

Author:

{'name': 'jason-price-mongodb', 'email': '69260375+jason-price-mongodb@users.noreply.github.com', 'username': 'jason-price-mongodb'}

Message: DOCS-15547 show record id (#1692) (#1700)

Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com>

Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com>
Branch: v5.0
https://github.com/10gen/docs-mongodb-internal/commit/12cf6278090ea02c9bd48859e6c1996c02e52ca3

Generated at Thu Feb 08 08:13:13 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.