On this page本页内容
cursor.showRecordId()
This is a mongosh
method. This is not the documentation for Node.js
or other programming language specific driver methods.
In most cases, mongosh
methods work the same way as the legacy mongo
shell methods. However, some legacy methods are unavailable in mongosh
.
For the legacy mongo
shell documentation, refer to the documentation for the corresponding MongoDB Server release:
For MongoDB API drivers, refer to the language specific MongoDB driver documentation.
Changed in version 3.2.在版本3.2中更改。
cursor.showDiskLoc()
.cursor.showDiskLoc()
。
Modifies the output of a query by adding a field 通过向匹配的文档添加字段$recordId
to matching documents. $recordId
来修改查询的输出。$recordId
is the internal key which uniquely identifies a document in a collection. $recordId
是唯一标识集合中文档的内部密钥。It has the form:其形式如下:
"$recordId": NumberLong(<int>)
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:showRecordId()
方法附加到db.collection.find()
方法,以便在匹配的文档中包含存储引擎记录信息:
db.collection.find( { a: 1 } ).showRecordId()
The operation returns the following documents, which include the 该操作返回以下文档,其中包括$recordId
field:$recordId
字段:
{ "_id" : ObjectId("53908ccb18facd50a75bfbac"), "a" : 1, "b" : 1, "$recordId" : NumberLong(168112) } { "_id" : ObjectId("53908cd518facd50a75bfbad"), "a" : 1, "b" : 2, "$recordId" : NumberLong(168176) }
You can project the added field 可以投影添加的字段$recordId
, as in the following example:$recordId
,如下例所示:
db.collection.find( { a: 1 }, { $recordId: 1 } ).showRecordId()
This query returns only the 此查询仅返回匹配文档中的_id
field and the $recordId
field in the matching documents:_id
字段和$recordId
字段:
{ "_id" : ObjectId("53908ccb18facd50a75bfbac"), "$recordId" : NumberLong(168112) } { "_id" : ObjectId("53908cd518facd50a75bfbad"), "$recordId" : NumberLong(168176) }